Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb 以数组为参数的查询,如何转换为GoLang mgo?_Mongodb_Go_Mongodb Query_Mgo - Fatal编程技术网

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}