allow multiple db wraps

This commit is contained in:
AJ ONeal 2017-05-30 01:39:21 +00:00
parent 1ae97267a0
commit 68e48800c3
1 changed files with 7 additions and 9 deletions

View File

@ -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) {