I have 2 structs:
type Customer struct {
MyID int `bson:"myID"`
}
type Bag struct {
Customer primitive.ObjectID `bson:"customer"`
}
But I dunno how to make filter to find document in Bag collection by Customer.MyID I tried something like this:
filter := bson.D{{"customer", bson.D{{"myID", 123456789}}}}
cur, err := collection.Find(context.TODO(), filter)
Also tried this:
filter := bson.D{{"customer.myID", bson.D{{"$eq", 123456789}}}}
cur, err := collection.Find(context.TODO(), filter)
And I always get nothing in my cur variable. Please help me how to use it right.