Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Programação web com Node e Express Beneficiando-se da stack JavaScript

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const config = require('../../config/database.js');

const db = {};
const sequelize = new Sequelize(config);

fs
  .readdirSync(__dirname)
  .filter(file => (file.indexOf('.') !== 0) && (file !== path.basename(__filename)) && (file.slice(-3) === '.js'))
  .forEach((file) => {
    const model = sequelize.import(path.join(__dirname, file));
    db[model.name] = model;
  });

Object.keys(db).forEach((modelName) => {
  if (db[modelName].associate) {
    db[modelName].associate(db);
  }
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
Comment

PREVIOUS NEXT
Code Example
Javascript :: unable to communicate with the paypal gateway in magento 2 
Javascript :: angry professor javascript 
Javascript :: program to parenthesize an expression 
Javascript :: elasticsearch reindex and rename field 
Javascript :: res : [ Circular ] nodejs 
Javascript :: [myobj.key] [myobj[key]] [myobj["key"]] answer 
Javascript :: javascript random point on unit sphere 
Javascript :: get the first value when mapping through the array 
Javascript :: image continuous changing div react 
Javascript :: cypress graphql request example 
Javascript :: cortar elemento y pegar en otro lugar jquery 
Javascript :: javascript Arranging Coins 
Javascript :: dropdown using ajax and django 
Javascript :: coldfusion cfscript cflocation 
Javascript :: set up chrome dev tools adonisjs 
Javascript :: formatDoubl js 
Javascript :: how to convert json to bootstrap treeview format 
Javascript :: package.json beginner 
Javascript :: apply event listener on id but why not style 
Javascript :: cordova read file in www folder 
Javascript :: monk find fields 
Javascript :: various elements of jsp document 
Javascript :: imasu ka meaning in japanese 
Javascript :: svelte reactive async 
Javascript :: -d {followingjson} curl 
Javascript :: json etudients 
Javascript :: rdlc refresh dataset from object 
Javascript :: dom javascript cheat sheet 
Javascript :: javascript see if chrome is in dark mode 
Javascript :: recorrer letra por letra js 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =