Created
October 15, 2022 09:49
-
-
Save zibellon/5d789a36fcce9ac741a8fa8b08118fe8 to your computer and use it in GitHub Desktop.
Index - DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Sequelize } = require("sequelize"); | |
//Создваем instance Sequelize | |
const sequelizeInstance = new Sequelize({ | |
// dialect: "postgres", | |
// host: "21.23.35.4", | |
// port: 6000, | |
// database: "js-todo", | |
// username: "postgres", | |
// password: "qwerty10", | |
dialect: "sqlite", | |
storage: "./sqliteData/database.sqlite", //Путь до файла с данными | |
}); | |
const initDB = async () => { | |
try { | |
await sequelizeInstance.authenticate(); //Авторизация нашей ORM в БД | |
// await sequelize.dropSchema('public', {}); | |
// await sequelize.createSchema('public', {}); | |
await sequelizeInstance.sync(); //Синхронизация МОДЕЛЕЙ | |
console.log("Sequelize was initialized"); | |
} catch (error) { | |
console.log("Sequelize ERROR (initDB)", error); | |
process.exit(); | |
} | |
}; | |
module.exports = { | |
sequelizeInstance, | |
initDB, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment