e6f7c706cb
- Created Role model - Created Permission model - Linked Users->Roles with a belongsToMany relationship - Linked Permissions to Users and Roles with a belongsToMany relationship - Created permissions helper with functions for initializing and checking permissions (canThis) - Unit tests for lots of things
28 lines
859 B
JavaScript
28 lines
859 B
JavaScript
/*global require, module */
|
|
|
|
(function () {
|
|
"use strict";
|
|
|
|
var GhostBookshelf = require('./base'),
|
|
knex = GhostBookshelf.Knex;
|
|
|
|
module.exports = {
|
|
Post: require('./post').Post,
|
|
User: require('./user').User,
|
|
Role: require('./role').Role,
|
|
Permission: require('./permission').Permission,
|
|
Setting: require('./setting').Setting,
|
|
init: function () {
|
|
return knex.Schema.hasTable('posts').then(null, function () {
|
|
// Simple bootstraping of the data model for now.
|
|
var migration = require('../data/migration/001');
|
|
return migration.down().then(function () {
|
|
return migration.up();
|
|
});
|
|
}).then(function () {
|
|
console.log('models loaded');
|
|
});
|
|
}
|
|
};
|
|
|
|
}()); |