mongodb geonear

  mongodb, question
What kind of collection do I need to prepare before using db.runcommand ((geonear: "collectionname", near: [120.123456, 30.654321, num: 10})?  The corresponding fields and indexes of the collection?  ?  ?

The collection needs to add coordinate information in GeoJson format, for example:

{ type: "Point", coordinates: [ 40, 5 ] }

You also need to build a 2dsphere type index, for example:

db.collection.createIndex( { <location field> : "2dsphere" } )

See mongodb’s documentation for more details:
https://docs.mongodb.org/manual/core/2dsphere/