2016-08-11 7 views
0

私は、次のクエリを持っている:配列をパラメータとしてクエリし、GoLang mgoに変換する方法は?

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, 
     }, 
    } 
+3

「$ center」:interface [] {interface [] { - 73.94075,40.789138}、5000} '? –

答えて

3

使用していません:

time.Now().Unix() * 1000 

があなたをした:

"$center": []interface{}{j.Location.Coordinates, 5000} 

この行はおそらく誤りでありますほしい+ 1000