function initializeModels(connection) { Enum = function() { this.adapter(connection.driver, {dbname: connection.dbname}); this.property('name', 'string', {required: true}); this.property('enumType', 'string', {required: false}); }; Enum = Model.register('Enum', Enum); }
var model = require('model'); var adapter = require('./..').adapter; var Issue = function () { this.adapter = adapter; this.property('url','string'); this.property('htmlUrl','string'); this.property('number','number'); this.property('state','string'); this.property('title','string'); this.property('body','string'); this.property('user','object'); this.property('labels','object'); this.property('assignee','object'); this.property('milestone','object'); this.property('comments','number'); this.property('pullRequest','object'); this.property('closedAt','date'); this.property('createdAt','date'); this.property('updatedAt','date'); }; model.register('Issue', Issue);
}; c.flash = { set:function (type, msg) { c.flashMessage = {type:type,msg:msg}; } }; return c; }; MockRequest = function () { this.headers = { accept: '*/*' } }; Zooby = model.register('Zooby', Zooby); // Just to make sure our lowest level method is working tests = { 'respond in html, format specified and supported': function (next) { var c = createController(); c.output = function (statusCode, headers, content) { assert.equal(200, statusCode); assert.equal('text/html', headers['Content-Type']); assert.equal('<div>{"zooby":"bar"}</div>', content); next(); }; c.respond({zooby: 'bar'}, {format: 'html'}); } , 'respond in html, format in params and supported': function (next) {
// this.validatesPresent('_id'); // this.validatesWithFunction('_id', function(val) { // return val.substring(0,2) == 'id_'; // }); // this.validatesLength('name', {is: 3, message: 'Try again, gotta be 3!'}); // this.beforeValidate = function(params) { // console.log('BEFORE VALIDATE: ', params); // }; // this.afterValidate = function(params) { // console.log('AFTER VALIDATE: ', params); // }; // }; // person = model.register('Person', person); var person = function() { this.property('name', 'string'); // this.validatesLength('name', {is: 3, message: 'Try again, gotta be 3!'}); this.validatesWithFunction('name', function(value, model) { console.log('value, model: %s, %s', value, JSON.stringify(model)); if(value == 'Sid') { return true; } else { return "You are not Sid... Piss off."; } }); } person = model.register('person', person); module.exports = person;
if (!params.path && params.title) { params.path = slugify(params.title); } if (!params.hkey && params.path) { params.hkey = params.path; } if (!params.id && params.hkey) { params.id = keyHash(params.hkey); } params.hidden = params.hidden || false; }; }; Page.count = function (where, done) { var opts = { count: true }; Page.all(where, opts, done); }; Page.close = function (cb) { Page.adapter.disconnect(cb); }; Page = Model.register('page', Page); module.exports = Page;
type: 'string', required: true }, highlighted: { type: 'boolean', required: true }, }; Note = model.register('Note', function() { this.defineProperties(noteProperties); //set up the storage adapter, can be set to one of many (as per mde/model) // this.setAdapter('filesystem', { // 'location': path.join(__dirname, '.model-fs'), // 'filename': 'note' // }); this.setAdapter('level', { 'db': storePath, }); // this.setAdapter('memory'); }); /* CRUD functionality */ function createNote(data, cb) { try { assertNotUndefined(data.instrument, 'create needs instrument'); assertNotUndefined(data.time, 'create needs time');