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 = {};
|
||||
function getSiteStore(clientUrih, pkgId, dir) {
|
||||
if (modelsCache[clientUrih]) {
|
||||
return modelsCache[clientUrih];
|
||||
if (!modelsCache[clientUrih]) {
|
||||
modelsCache[clientUrih] = apiFactories.systemSqlFactory.create({
|
||||
init: true
|
||||
, dbname: clientUrih // '#' is a valid file name character
|
||||
});
|
||||
}
|
||||
|
||||
// DB scopes:
|
||||
|
@ -92,19 +95,14 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
|||
// scope Experience to db
|
||||
// scope Api by table
|
||||
// scope Account and Client by column
|
||||
modelsCache[clientUrih] = apiFactories.systemSqlFactory.create({
|
||||
init: true
|
||||
, dbname: clientUrih // '#' is a valid file name character
|
||||
}).then(function (db) {
|
||||
return modelsCache[clientUrih].then(function (db) {
|
||||
var wrap = require('masterquest-sqlite3');
|
||||
|
||||
return wrap.wrap(db, dir).then(function (models) {
|
||||
modelsCache[clientUrih] = PromiseA.resolve(models);
|
||||
//modelsCache[clientUrih] = PromiseA.resolve(models);
|
||||
return models;
|
||||
});
|
||||
});
|
||||
|
||||
return modelsCache[clientUrih];
|
||||
}
|
||||
|
||||
function loadRestHelper(myConf, clientUrih, pkgId) {
|
||||
|
|
Loading…
Reference in New Issue