greenlock-store-sequelize.js/db/index.js

26 lines
483 B
JavaScript
Raw Normal View History

'use strict';
var path = require('path');
var sync = require('../sync.js');
2019-05-09 06:35:02 +00:00
module.exports = function (sequelize) {
var db = {};
2019-05-09 06:35:02 +00:00
[ 'keypair.js'
, 'domain.js'
, 'certificate.js'
, 'chain.js'
].forEach(function (file) {
var model = sequelize['import'](path.join(__dirname, file));
2019-04-10 14:11:38 +00:00
db[model.name] = model;
});
Object.keys(db).forEach(function (modelName) {
2019-05-09 06:35:02 +00:00
db[modelName].associate(db);
});
2019-05-09 06:35:02 +00:00
return sync(db).then(function () {
return db;
});
};