-
-
Save jaimemin/c30f4d0fa418cdd24de6ff73bfbe1070 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 2dsphere 인덱스 생성 | |
| db.places.createIndex({ location: "2dsphere" }); | |
| // 근처 장소 쿼리하기 | |
| db.places.find({ | |
| location: { | |
| $near: { | |
| $geometry: { type: "Point", coordinates: [-73.9667, 40.78]}, | |
| $maxDistance: 500 | |
| } | |
| } | |
| }) | |
| // 지정된 다각형 내의 문서 쿼리하기 | |
| db.places.find({ | |
| location: { | |
| $geoWithin: { | |
| $geometry: { | |
| type: "Polygon", | |
| coordinates: [ | |
| [ | |
| [0, 0], | |
| [3, 6], | |
| [6, 1], | |
| [0, 0] | |
| ] | |
| ] | |
| } | |
| } | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment