Created
July 16, 2020 10:23
-
-
Save moaoa/0a60ede30d0a045fb43e1d93dd1fe0ad to your computer and use it in GitHub Desktop.
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
// With a JSON doc | |
Person. | |
find({ | |
occupation: /host/, | |
'name.last': 'Ghost', | |
age: { $gt: 17, $lt: 66 }, | |
likes: { $in: ['vaporizing', 'talking'] } // see if the value of likes included in ['vaporizing, 'talking'] array | |
// syntax {property: {$in: array...}} | |
}). | |
limit(10). | |
sort({ occupation: -1 }). | |
select({ name: 1, occupation: 1 }). | |
exec(callback); | |
// Using query builder | |
Person. | |
find({ occupation: /host/ }). | |
where('name.last').equals('Ghost'). | |
where('age').gt(17).lt(66). | |
where('likes').in(['vaporizing', 'talking']). | |
limit(10). | |
sort('-occupation'). | |
select('name occupation'). | |
exec(callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment