2013-05-17 01:16:09 +04:00
|
|
|
/**
|
|
|
|
* 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'),
|
2013-05-24 08:02:41 +04:00
|
|
|
PostsProvider = require('./dataProvider.bookshelf.posts'),
|
|
|
|
UsersProvider = require('./dataProvider.bookshelf.users'),
|
2013-05-17 01:16:09 +04:00
|
|
|
DataProvider,
|
|
|
|
instance;
|
|
|
|
|
|
|
|
DataProvider = function () {
|
|
|
|
if (!instance) {
|
|
|
|
instance = this;
|
|
|
|
knex.Schema.hasTable('posts').then(null, function () {
|
|
|
|
// Simple boostraping of the data model for now.
|
2013-05-24 08:02:41 +04:00
|
|
|
require('../data/migration/001').up().then(function () {
|
2013-05-17 01:16:09 +04:00
|
|
|
console.log('all done....');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
};
|
|
|
|
|
2013-05-24 08:02:41 +04:00
|
|
|
DataProvider.prototype.posts = new PostsProvider();
|
|
|
|
DataProvider.prototype.users = new UsersProvider();
|
2013-05-21 05:03:35 +04:00
|
|
|
|
2013-05-17 01:16:09 +04:00
|
|
|
module.exports = DataProvider;
|
|
|
|
}());
|