Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

NodeJS Database initialisation

const sequelize = new Sequelize('DBNAME', 'USER', 'PASSWORD', { // create a sequelize instance (connect to DB)
    dialect: "LANGAGE", // mysql, mariadb, etc...
    host: "YOUR-HOST"
});

const initDB = () => {
    sequelize.sync({force:  true}) 
    .then(_ => {
    console.log('DB  OK')
    })
    .catch(err => console.error('DB K.O', err));
}

// If not used in app.js 

module.exports = {
    initDB
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: cookie in Auth header 
Javascript :: js how to get random number (inclusive min max) and push it in an array 
Javascript :: Assigning A Property The Return Value Of A Function In Class 
Javascript :: Function Written In Constructor Involving A Promise, Can Be Accessed As Below 
Javascript :: JavaScript Using es6(ES2015) Destructuring assignment 
Javascript :: Joi conditional validation refer parent object 
Javascript :: Inside Fetch Is A Request 
Javascript :: check if can go back react native 
Javascript :: path.join javascript one folder above 
Javascript :: JavaScript HTMLCollection Object 
Javascript :: disable scroll increment in react js number type 
Javascript :: mul function call to 3 functions 
Javascript :: How to Loop Through an Array with a While Loop in JavaScript 
Javascript :: connect nextjs to google sheets 
Javascript :: Backbone + Express 
Javascript :: javascript nodejs array to listnode 
Javascript :: discord.js profile picture 
Javascript :: radio button remove checked 
Javascript :: data.json 
Javascript :: promise object 
Javascript :: higher order function javascript 
Javascript :: switch 
Javascript :: how to remove duplicates in js 
Javascript :: sweetalert2 redirect after ok 
Javascript :: how to add prefix to a string in javascript 
Javascript :: why null is an object in javascript 
Javascript :: eager loading 
Javascript :: javascript map size 
Javascript :: javascript Number() Method Used on Dates 
Javascript :: JavaScript / jQuery DOM Selectors 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =