Mongorito Tcomb
Bring schema validation to Mongorito thanks to tcomb
Install
npm i -S mongorito-tcomb
Usage (ES6)
// 1. Import the dependencies // 2. Let's define some Model // We add the optional Schema { return t; } { return t; } ;
For coffeescript, you can see examples
API
Mixins
patch: (Model) -> PatchedModel
The patch function can be useful to combine different Mongorito plugins. It take a class, extend it then return the extended class.
Customs tcomb types
t.unique
It ensure that the type is unique in the database.
Usage: t.unique(T)
where T is any tcomb type
t.ID
It represent the ID of an element in the database.
Usage: t.ID(M)
where M is a Mongorito model
It ensure that ID is valid and exist in the database
TODOS
- More human exceptions