1.4.11 • Published 8 years ago
document.js v1.4.11
document.js
#Getting started
###Install it
$ npm install document.js
###Require it
var store = decidingFactor ? 'mongo' : 'memory';
Document = require('document.js/lib/index')({store: store});
###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'],
// hasMany: ['messages'], TODO
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.
1.4.11
8 years ago
1.4.10
8 years ago
1.4.9
8 years ago
1.4.8
9 years ago
1.4.7
9 years ago
1.4.6
9 years ago
1.4.5
9 years ago
1.4.4
9 years ago
1.4.3
9 years ago
1.4.2
9 years ago
1.4.1
9 years ago
1.4.0
9 years ago
1.3.1
9 years ago
1.3.0
9 years ago
1.2.5
9 years ago
1.2.4
9 years ago
1.2.3
9 years ago
1.2.2
9 years ago
1.2.1
9 years ago
1.2.0
9 years ago
1.1.3
9 years ago
1.1.2
9 years ago
1.1.1
9 years ago
1.1.0
9 years ago
1.0.3
9 years ago
1.0.2
9 years ago
1.0.1
9 years ago
0.9.7
9 years ago
0.9.6
9 years ago
0.9.5
9 years ago
0.9.4
9 years ago
0.9.3
9 years ago
0.9.2
9 years ago
0.9.1
9 years ago
0.9.0
9 years ago