Sample Data:

db.games.insertMany(
[
{
    teamA: "Chickens",
    teamB: "Turkeys",
    sport: "Golf",
    time: "1230",
    whereat: {
        type: "Point",
        coordinates: [-122.349274, 47.620506], //longitude first, then latitude.
        address: "Space needle"
    }
},
{
    teamA: "Rhinos",
    teamB: "Goldfish",
    sport: "Chess",
    time: "1450",
    whereat: {
        type: "Point",
        coordinates: [-73.940033, 40.757801], //longitude first, then latitude.
        address: "Queens, New York"
    }
},
{
    teamA: "meerkats",
    teamB: "warthogs",
    sport: "hot dog eating",
    time: "0222",
    whereat: {
        type: "Point",
        coordinates: [-95.370800, 29.748690], //longitude first, then latitude.
        address: "2017 Main st Houston, Tx"
    }
},
{
    teamA: "red",
    teamB: "blue",
    sport: "Halo 2",
    time: "4:55pm",
    whereat: {
        type: "Point",
        coordinates: [-122.205986, 47.676891], //longitude first, then latitude.
        address: "Kirkland, WA"
    }
},
{
    teamA: "apes",
    teamB: "burrito boys",
    sport: "soccer",
    time: "4:20pm",
    whereat: {
        type: "Point",
        coordinates: [-122.441528, 47.253078], //longitude first, then latitude.
        address: "Tacoma, WA"
    }
},
])

Create the “index” on the “whereat” object.

db.games.createIndex( {whereat: "2dsphere"} )

Find games within specified distance from the specified coordinates:

// get all games within 1000 meters of Everett. (returns 0 because 1000 meters isn't very far)
db.games.find({
    whereat: {
        $nearSphere: {
            $geometry: {
                type: "Point",
                coordinates: [-122.202080, 47.978985] // everett, wa
            },
            $maxDistance: 1000 // meters
        }
    }
})


// Returns 3 results: Everett & Tacoma are within 100000 meters of each other.
db.games.find({
    whereat: {
        $nearSphere: {
            $geometry: {
                type: "Point",
                coordinates: [-122.202080, 47.978985] // everett, wa
            },
            $maxDistance: 100000
        }
    }
})

// Finally gets all 5 results due to a much larger $maxDistance
db.games.find({
    whereat: {
        $nearSphere: {
            $geometry: {
                type: "Point",
                coordinates: [-122.202080, 47.978985] // everett, wa
            },
            $maxDistance: 10000000
        }
    }
})