greenlock-store-sequelize.js/sync.js

23 lines
403 B
JavaScript

'use strict';
function sync(db) {
var keys = Object.keys(db);
function next() {
var modelName = keys.shift();
if (!modelName) { return; }
if (isModel(modelName)) {
return db[modelName].sync().then(next);
}
return next();
}
return Promise.resolve().then(next);
}
function isModel(key) {
return !(['sequelize','Sequelize'].includes(key));
}
module.exports = sync;