2013-05-17 17:54:14 +00:00
|
|
|
var ADL = require('../../jugglingdb').ADL;
|
|
|
|
var adl = new ADL();
|
2013-05-17 15:49:57 +00:00
|
|
|
// define models
|
2013-05-17 17:54:14 +00:00
|
|
|
var Post = adl.define('Post', {
|
2013-05-17 15:49:57 +00:00
|
|
|
title: { type: String, length: 255 },
|
2013-05-17 17:54:14 +00:00
|
|
|
content: { type: ADL.Text },
|
2013-05-17 15:49:57 +00:00
|
|
|
date: { type: Date, default: function () { return new Date;} },
|
|
|
|
timestamp: { type: Number, default: Date.now },
|
|
|
|
published: { type: Boolean, default: false, index: true }
|
|
|
|
});
|
|
|
|
|
|
|
|
// simplier way to describe model
|
2013-05-17 17:54:14 +00:00
|
|
|
var User = adl.define('User', {
|
2013-05-17 15:49:57 +00:00
|
|
|
name: String,
|
2013-05-17 17:54:14 +00:00
|
|
|
bio: ADL.Text,
|
2013-05-17 15:49:57 +00:00
|
|
|
approved: Boolean,
|
|
|
|
joinedAt: Date,
|
|
|
|
age: Number
|
|
|
|
});
|
|
|
|
|
2013-05-17 17:54:14 +00:00
|
|
|
var Group = adl.define('Group', {name: String});
|
2013-05-17 15:49:57 +00:00
|
|
|
|
|
|
|
// define any custom method
|
|
|
|
User.prototype.getNameAndAge = function () {
|
|
|
|
return this.name + ', ' + this.age;
|
|
|
|
};
|
|
|
|
|
|
|
|
var user = new User({name: 'Joe'});
|
|
|
|
console.log(user);
|
|
|
|
|
2013-05-17 17:54:14 +00:00
|
|
|
console.log(adl.models);
|
|
|
|
console.log(adl.definitions);
|
2013-05-17 15:49:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|