Last active
August 29, 2015 13:58
-
-
Save kjirou/9968231 to your computer and use it in GitHub Desktop.
mongoose のクエリ例
This file contains 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
// Ref) http://mongoosejs.com/docs/queries.html | |
Person | |
.find({ occupation: /host/ }) | |
.where('name.last').equals('Ghost') | |
.where('age').gt(17).lt(66) | |
.where('likes').in(['vaporizing', 'talking']) | |
.limit(10) | |
//.skip(1) // これもある | |
.sort('-occupation') | |
.select('name occupation') // fields オプションと同じ、{name:1, occupation:1} と同じ意味 | |
.exec(callback); // find にコールバックを入れるとこれを実行したのと同じになる、入れないとクエリオブジェクトのまま |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment