LearnBoost/mongoose — Issue #679: Documenting NamedScope
Author: fzaninotto
Created: 2012-01-11 11:41:05+00:00
State: open

Found no dococumentation on named scopes. The code is not succifient, at least an example is necessary.

Here is what could bootstrap this doc:

```js
var Foo = new Schema({
name : String
, value : { type: Number, default: 0 }
});

Foo.namedScope('byValue', function(order) {
if (typeof order == 'undefined' || order == 'asc') {
return this.find({}).asc('value');
} else {
return this.find({}).desc('value');
}
});

Foo.byValue().find({});
```