Skip to content

Instantly share code, notes, and snippets.

@windwp
Last active July 6, 2018 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windwp/7387368631f5905288e27550442b929b to your computer and use it in GitHub Desktop.
Save windwp/7387368631f5905288e27550442b929b to your computer and use it in GitHub Desktop.
// truy van 1 truong nao` do' boi? deepPopulate
.deepPopulate('user.business',{populate:{'user' :{select:'displayName profileImageURL business'},'user.business': { select: 'url'}}})
//truy van 1 thanh phan nao` do' trong 1 mang
if( req.query.suburb){
searchQuery.suburbs = {$elemMatch: {name: req.query.suburb, enabled: true}};
}
//loai. bo? 1 phan tu? khoi? ketu qua try van
User.findOne({personcode: code})
.select('-_id -__v')
.populate('bookids', '-_id -__v')
.exec(function (err, data) {
//foo
});
//find by name
search: {
name: { '$regex': value, '$options': 'i' }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment