34 lines
856 B
JavaScript
Executable File
34 lines
856 B
JavaScript
Executable File
// eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}]
|
|
|
|
// Load environment variables from .env file
|
|
require("dotenv").config();
|
|
|
|
// Import database client
|
|
const database = require("./database/client");
|
|
|
|
const insertUsers = async () => {
|
|
return database.query(`
|
|
INSERT INTO users (nickname, mail, password, tetardcoin) VALUES
|
|
('Tetardtek', 'kvnn64@gmail.com', '$2b$10$4VWdZ7SANvRr7qn3k6LAEu6eGApGQUvPOqcCCmgzVLKNlSpBL0rGa', 1000)
|
|
`);
|
|
};
|
|
|
|
const seed = async () => {
|
|
try {
|
|
await database.query("START TRANSACTION");
|
|
|
|
await insertUsers();
|
|
|
|
await database.query("COMMIT");
|
|
|
|
database.end();
|
|
|
|
console.info(`${database.databaseName} filled from ${__filename} 🌱`);
|
|
} catch (err) {
|
|
await database.query("ROLLBACK");
|
|
console.error("Error filling the database:", err.message);
|
|
}
|
|
};
|
|
|
|
seed();
|