Mongodb 以数组为参数的查询,如何转换为GoLang mgo?
我有以下疑问:Mongodb 以数组为参数的查询,如何转换为GoLang mgo?,mongodb,go,mongodb-query,mgo,Mongodb,Go,Mongodb Query,Mgo,我有以下疑问: db.getCollection('spawnlocations').find({ 'location': { '$geoWithin': { '$center': [[-73.94075, 40.789138], 5000] } }, "expirationtimems": { "$gte": 1234567890 }, "_id": { "$gte": "2a920240836c40d
db.getCollection('spawnlocations').find({
'location': {
'$geoWithin': {
'$center': [[-73.94075, 40.789138], 5000]
}
},
"expirationtimems": { "$gte": 1234567890 },
"_id": { "$gte": "2a920240836c40d8b374203a798a27fa.16" }
}).sort({"_id":1}).limit(50)
我正试图使用bson.M
将查询转换为mgo,但我对其中的数组部分感到很难
我原以为这样行得通,但当然不行
q = bson.M{
"location": bson.M{
"$geoWithin": bson.M{
"$center": [
j.Location.Coordinates,
5000
],
},
},
"expirationtimems": bson.M{
"$gte": time.Now().Unix() * 1000,
},
"_id": bson.M{
"$gt": p,
},
}
使用以下命令:
"$center": []interface{}{j.Location.Coordinates, 5000}
这一行可能是一个错误:
time.Now().Unix() * 1000
您想要+1000
?使用此选项:
"$center": []interface{}{j.Location.Coordinates, 5000}
这一行可能是一个错误:
time.Now().Unix() * 1000
你想要+1000
?“$center”:接口[]{interface[]{-73.94075,40.789138},5000}?“$center”:接口[]{interface[]{-73.94075,40.789138},5000}
?