Help with query

46 views
Skip to first unread message

Olmedo Arcila Guzmán

unread,
Feb 8, 2018, 1:23:26 PM2/8/18
to mgo-users

I run this query in mongo console, and it work fine


db.entities.find({$and: [{"entityType.value":9},{entityId:{$gte:"1998852"}},{entityId:{$lt:"2210000"}}]}).sort({entityId:1})


Then, I trying to write in golang but dont works.


q1 := bson.M{"entityType.value": 4}
q2 := bson.M{"entityId": bson.M{"$gte": "1998852"}}
q3 := bson.M{"entityId": bson.M{"$lt": "2210000"}}
query := bson.M{"$and": bson.D{q1, q2, q3}}


db.C("entities").Find(query).All(&result)


Some idea to do that??



Diego Medina

unread,
Feb 8, 2018, 4:24:54 PM2/8/18
to mgo-users
Hi,

Your shell command used 9 for entityType but mgo has 4

If that is not it, what error are you getting when you run the mgo query?
Reply all
Reply to author
Forward
0 new messages