23 lines
433 B
JavaScript
23 lines
433 B
JavaScript
'use strict';
|
|
|
|
function syncSequelizeModels(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 = syncSequelizeModels;
|