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

🐞 Bug Alert: InsertOne returns ObjectID("000000000000000000000000") instead of actual id #16

Open
moinologics opened this issue Mar 5, 2024 · 0 comments

Comments

@moinologics
Copy link

moinologics commented Mar 5, 2024

Describe the bug
InsertOne returns ObjectID("000000000000000000000000") in _id instead of actual id

How To Reproduce

type User struct {
  ID      primitive.ObjectID `json:"id" bson:"_id,omitempty"`
  Name    string             `json:"name" bson:"name"`
}

model := types.User{}
opts := schemaopt.SchemaOptions{Collection: "users"}
userModel, err := mgod.NewEntityMongoModel(model, opts)

user := User{Name: "abc"}

user = userModel.InsertOne(context.Background(), user)

fmt.Println(user.ID)

Expected behavior
should return actual objectId of created doc

Environment (please complete the following information):

  • OS: mac 14
  • GO: go1.21.0 darwin/arm64
  • Package version: v0.4.0 (v0.3.1)
  • Mongodb version: MongoDB 7.0.0 Community

Additional context
Add any other context about the problem here.

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