In Rails there is default_scope (http://apidock.com/rails/ActiveRecord/Scoping/Default/ClassMethods/default_scope) which allows specifying a default set of rules that are applied, when querying models from database. Is there a way to do the same thing in Mongoose?
I don't think such a thing exists, but you could create your own version of, for instance, find:
yourSchema.static('myFind', function() {
var query = arguments[0];
...augment your query here...
return this.find.apply(this, arguments);
});
And instead of Model.find(), you use Model.myFind().