allow multiple db wraps
This commit is contained in:
parent
1ae97267a0
commit
68e48800c3
16
lib/apis.js
16
lib/apis.js
|
@ -78,8 +78,11 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
|
|
||||||
var modelsCache = {};
|
var modelsCache = {};
|
||||||
function getSiteStore(clientUrih, pkgId, dir) {
|
function getSiteStore(clientUrih, pkgId, dir) {
|
||||||
if (modelsCache[clientUrih]) {
|
if (!modelsCache[clientUrih]) {
|
||||||
return modelsCache[clientUrih];
|
modelsCache[clientUrih] = apiFactories.systemSqlFactory.create({
|
||||||
|
init: true
|
||||||
|
, dbname: clientUrih // '#' is a valid file name character
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// DB scopes:
|
// DB scopes:
|
||||||
|
@ -92,19 +95,14 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
// scope Experience to db
|
// scope Experience to db
|
||||||
// scope Api by table
|
// scope Api by table
|
||||||
// scope Account and Client by column
|
// scope Account and Client by column
|
||||||
modelsCache[clientUrih] = apiFactories.systemSqlFactory.create({
|
return modelsCache[clientUrih].then(function (db) {
|
||||||
init: true
|
|
||||||
, dbname: clientUrih // '#' is a valid file name character
|
|
||||||
}).then(function (db) {
|
|
||||||
var wrap = require('masterquest-sqlite3');
|
var wrap = require('masterquest-sqlite3');
|
||||||
|
|
||||||
return wrap.wrap(db, dir).then(function (models) {
|
return wrap.wrap(db, dir).then(function (models) {
|
||||||
modelsCache[clientUrih] = PromiseA.resolve(models);
|
//modelsCache[clientUrih] = PromiseA.resolve(models);
|
||||||
return models;
|
return models;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return modelsCache[clientUrih];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadRestHelper(myConf, clientUrih, pkgId) {
|
function loadRestHelper(myConf, clientUrih, pkgId) {
|
||||||
|
|
Loading…
Reference in New Issue