bson.M type does not implement Context
lowl11 opened this issue · 1 comments
Description of the bug
I tried to use package by a tutorial in README. And first thing I wanted to do is get one record by field (filter).
Then I used this line of code from README coll.FindOne(bson.M{"id": userID}, user)
to get record.
Shortly
Impossible to use bson.M{}
because lint says:
"Cannot use 'bson.M{"id": userID}' (type M) as type context.Context Type does not implement 'context.Context' as some methods are missing: Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error ..."
Possible solution the issue
I am not sure in that solution!
Environment:
- Golang Version: 1.14
- mgm version (tag): 3.0.1
Your provided params are wrong, the first param of FindOne
method must be a context not a bson.M
.
Something like this:
coll := mgm.Coll(&Book{})
coll.FindOne(ctx,bson.M{})
I think you want to use the First
method:
coll.First(bson.M{"id": userID}, user)