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

Lower case problem #322

Open
alpcanm opened this issue Mar 25, 2023 · 0 comments
Open

Lower case problem #322

alpcanm opened this issue Mar 25, 2023 · 0 comments

Comments

@alpcanm
Copy link

alpcanm commented Mar 25, 2023

In my case , ı'm using mongodb driver. In this model "SecondId" decoded correctly but "ID" doesn't decode it would be 000000000000 because "ID" bson starts with lower case letter or underline. When i make bson:"_id" to bson:"Id" it works correctly but i can't do this because mongodriver doesn't work that way correctly. Id parameter should be "_id".

type MyModel struct {
	ID        primitive.ObjectID `bson:"_id" json:"id" `
	SecondId  primitive.ObjectID `bson:"SecondId,omitempty" json:"secondId"`
	CreatedAt int64              `bson:"CreatedAt,omitempty" json:"createdAt"`
	Text      string             `bson:"Text,omitempty" json:"text"`
}

output:

{
  id: '000000000000000000000000',
  secondId: '641c35cb74774ce4845114ba',
  createdAt: 1679768385584,
  text: 'test text'
}
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

1 participant