Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as fs from 'fs';
- import * as path from 'path';
- import Sequelize from 'sequelize';
- const baseFolder = __dir;
- const indexFile = 'index.js';
- const Op = Sequelize.Op;
- const operatorsAliases = {
- $eq: Op.eq,
- $ne: Op.ne,
- $gte: Op.gte,
- $gt: Op.gt,
- $lte: Op.lte,
- $lt: Op.lt,
- $not: Op.not,
- $in: Op.in,
- $notIn: Op.notIn,
- $is: Op.is,
- $like: Op.like,
- $notLike: Op.notLike,
- $iLike: Op.iLike,
- $notILike: Op.notILike,
- $regexp: Op.regexp,
- $notRegexp: Op.notRegexp,
- $iRegexp: Op.iRegexp,
- $notIRegexp: Op.notIRegexp,
- $between: Op.between,
- $notBetween: Op.notBetween,
- $overlap: Op.overlap,
- $contains: Op.contains,
- $contained: Op.contained,
- $adjacent: Op.adjacent,
- $strictLeft: Op.strictLeft,
- $strictRight: Op.strictRight,
- $noExtendRight: Op.noExtendRight,
- $noExtendLeft: Op.noExtendLeft,
- $and: Op.and,
- $or: Op.or,
- $any: Op.any,
- $all: Op.all,
- $values: Op.values,
- $col: Op.col
- };
- fs
- .readdirSync(baseFolder)
- .filter(file => (file.indexOf('.') !== 0) && (file !== indexFile) && (file.slice(-3) === '.js'))
- .forEach(file => {
- sequelize['import'](path.join(baseFolder, file));
- });
- Object.values(sequelize.models).forEach( Model => {
- Model.sync();
- if(Model.associate) {
- Model.associate();
- }
- });
- export default sequelize;
Add Comment
Please, Sign In to add comment