Answer the question
In order to leave comments, you need to log in
How in mgo.v2 to select data by one field but with different given values?
Good day to all.
There is a base with documents of goods. Products are from different manufacturers.
From the frontend there is a request for a selection of goods (the Manufacturer field), for 2 manufacturers: HP, Xerox.
It is necessary to select documents that meet the condition from the database.
Displaying all products of one manufacturer is not a problem:
query := bson.M{"manufacture": "hp"}
var list []Tovar
err = c.Find(query).All(&list)
query := bson.M{
"manufacture": [{"hp"},{"Xerox"}]}
coll.Find(
context.Background(),
bson.D{{"status", bson.D{{"$in", bson.A{"A", "D"}}}}})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question