0

I have the following query:

db.getCollection('spawnlocations').find({
    'location': {
        '$geoWithin': {
            '$center': [[-73.94075, 40.789138], 5000]
        }
    }, 
    "expirationtimems": { "$gte": 1234567890 }, 
    "_id": { "$gte": "2a920240836c40d8b374203a798a27fa.16" }
}).sort({"_id":1}).limit(50)

I am trying to convert the query to mgo using bson.M but I'm having a hard time with the array part of it.

I thought this would work, but of course it doesn't

    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,
        },
    }
1
  • 3
    "$center": interface[]{interface[]{-73.94075,40.789138}, 5000} ? Commented Aug 11, 2016 at 9:45

1 Answer 1

4

Use this:

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

This line is probably an error:

 time.Now().Unix() * 1000

Did you want + 1000?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.