24 lines
784 B
JavaScript
Executable file
24 lines
784 B
JavaScript
Executable file
import { Sequelize, DataTypes } from 'sequelize';
|
|
import { privateKey } from '../../config/privateKeys.js'; // Make sure your DB string is stored here
|
|
|
|
// Create a new Sequelize instance with the PostgreSQL connection string
|
|
const sequelize = new Sequelize(privateKey.DB_STRING_DEV, {
|
|
dialect: 'postgres', // The database dialect
|
|
logging: false, // Disable logging (optional)
|
|
});
|
|
|
|
// Test the connection to ensure it's working
|
|
const connectDb = async () => {
|
|
try {
|
|
await sequelize.authenticate();
|
|
console.log('Database connection established');
|
|
} catch (err) {
|
|
console.error('Error connecting to the database:', err);
|
|
}
|
|
};
|
|
|
|
connectDb();
|
|
|
|
// Export the Sequelize instance to use in other parts of the application
|
|
export { sequelize };
|