document.js
#Getting started
###Install it
$ npm install document.js
###Require it
var Document = require('document.js');
###Use it
Channel = Document.progeny('Channel', {
}, {
classMethods: {
fields: {
String: { slug: 's', name: 'n', token: 't' },
Date: { firstMessageAt: 'fma' },
Integer: { keepAlive: 'ka', buffered: 'b', capped: 'c' },
Object: { info: 'i' }
},
belongsTo: ['user'],
allow: ['name', 'token', 'userId', 'firstMessageAt', 'buffered', 'capped'],
validate: {
presence: ['name', 'userId'],
format: { slug: /^#\w{4,16}/ },
custom: [
function() { return Object.keys(this.get('info')).length > 0 }
]
},
beforeCreate: [
function() {
this.set('token', '{{random token generator}}');
}
]
}
});
For the full API see the document definition docs.