mercredi 25 février 2015

Mongoose default filter/query params for find()

If I have a collection of docs such as:



{
type: 'post',
text: 'example',
status: 'private' // or 'public'
}


What kind of middleware or schema config can I use to make sure that by default, Model.find() only returns docs where status != 'private' ?


I don't want to have to have to redundantly query for status != 'private' every single time I query the collection.


Thanks for the help!


Aucun commentaire:

Enregistrer un commentaire