In documentation i haven’t found any example of it.
In mongo bash (Compass), i use it
db.inventory.find( { quantity: { $in: [ 5, 15 ] } }, { _id: 0 } )
and it works, but if i use this code in golang, i get null:
type List struct {
SortKey string `json:"sortKey"`
SortValue int64 `json:"sortValue"`
Limit int64 `json:"limit"`
Skip int64 `json:"skip"`
Arr []int64 `json:"body"`
}
opts := options.Find().SetProjection(bson.M{"username": 1, "title": 1}).SetLimit(data.Limit).SetSkip(data.Skip).SetSort(bson.D{{Key: data.SortKey, Value: data.SortValue}})
filter := bson.M{"field": bson.M{"$in": data.Arr}}
cursor, _ := users.Find(ctx, filter, opts)
cursor.All(ctx, &list)
If i remove filter := bson.M{“field”: bson.M{"$in": data.Arr}}, then it works, but with it no…