Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
}
 
PREVIOUS NEXT
Tagged: #NodeJS #Database #initialisation
ADD COMMENT
Topic
Name
8+5 =