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.