Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

illegal document key when supplied with empty _key #145

Closed
MrDHat opened this issue Aug 16, 2018 · 2 comments
Closed

illegal document key when supplied with empty _key #145

MrDHat opened this issue Aug 16, 2018 · 2 comments

Comments

@MrDHat
Copy link

MrDHat commented Aug 16, 2018

I am facing an issue wherein whenever I try to save a struct, it says illegal document key. Here is what the struct looks like:

type User struct {
    Email     string    `json:"email"`
    Name      string    `json:"name"`
    Password  string    `json:"password"`
    DBKey     string    `json:"_key,omitmepty"`
    DBID      string    `json:"_id,omitmepty"`
    DBRev     string    `json:"_rev,omitmepty"`
    CreatedAt time.Time `json:"createdAt"`
    UpdatedAt time.Time `json:"updatedAt"`
    DeletedAt time.Time `json:"deletedAt"`
}

I am guessing it is because _key comes as an empty string when I pass along an object of this struct. I do not want to generate the keys at my end and want to rely on arango for the same.
Is there a workaround to this?

@ewoutp
Copy link
Contributor

ewoutp commented Aug 16, 2018

Replace omitmepty with omitempty in your struct fields.

@MrDHat
Copy link
Author

MrDHat commented Aug 16, 2018

Oh man! thanks a lot! 7 years of programming and these bugs still crop in :)

@MrDHat MrDHat closed this as completed Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants