Minimodel
Minimal, database agnostic Models for Node.js and the Browser.
The idea is to implement a Domain Model System that is persitence agnostic, to be used only for validation, type casting, transormations, and business logic. By using minimodel
, persintence (if relevant) has to be delegated to an external component (e.g. DAO/Services).
Advantages
- The same model can be retrieved from different data sources
- Easily reuse the same models in the Browser
- Custom persitence allows more fine grained and powerful queries (instead of using an imposed ORM style querying system)
Features
- Define schemas with a syntax similar to Mongoose's
- Type checking/casting
- Defaults
- Validation
- Virtuals
- Custom getters/setters
Usage
var minimodel = ; var Post = minimodel; //create a postvar post = id: Date author: fullname: "John Doe" ; //set a field after creationpost;//orpostauthorname = 'Johnny' //get a fieldconsole;//orconsole;
Stability
1 - Experimental
Please try it out and provide feedback.
What's new
0.2
- Breaking changes:
validate()
is now an async function. A callback could be given as argument otherwise a promise will be returned.