Ghost/core/shared/models/dataProvider.bookshelf.js

33 lines
918 B
JavaScript
Raw Normal View History

/**
* Provides access to data via the Bookshelf ORM
*/
/*globals module, require, process */
(function () {
"use strict";
2013-05-19 23:17:21 +04:00
var knex = require('./knex_init'),
PostsProvider = require('./dataProvider.bookshelf.posts'),
UsersProvider = require('./dataProvider.bookshelf.users'),
DataProvider,
instance;
DataProvider = function () {
if (!instance) {
instance = this;
knex.Schema.hasTable('posts').then(null, function () {
// Simple boostraping of the data model for now.
require('../data/migration/001').up().then(function () {
console.log('all done....');
});
});
}
return instance;
};
DataProvider.prototype.posts = new PostsProvider();
DataProvider.prototype.users = new UsersProvider();
module.exports = DataProvider;
}());