README
Mould.js
Define Schema on Database level.
Document validation has been introduced to MongoDb since version 3.2 . Before that, we could only define schema on application level.
Differences between Mould.js and Mongoose
| Feature | Mongoose | Mould.js |
|---|---|---|
| Schema Level | Application | Database |
| Features | Full | Minimal |
Get Started with Database Level Schema Validation
Attention:
mongodbversion >= 3.2 required
- Installation
npm install mouldjs --save
- Define Schema
let Mould = require('mouldjs')
let User = new Mould({
name : {$type: 'string', $exists: true},
age : {$type: 'int', $lt: 200},
email : {$regex: \"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+