working with postgres
This commit is contained in:
parent
d8a72e5978
commit
1ef39baa57
6 changed files with 186 additions and 9 deletions
|
|
@ -7,6 +7,12 @@ const sequelize = require('./database');
|
|||
const Session = require('./models/Session');
|
||||
const SessionNpubbed = require('./models/SessionNpubbed');
|
||||
|
||||
sequelize.sync().then(() => {
|
||||
console.log('Database synced');
|
||||
}).catch(err => {
|
||||
console.error('Error syncing the database:', err);
|
||||
});
|
||||
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
|
|
@ -45,6 +51,7 @@ app.post('/api/session-npubbed', async (req, res) => {
|
|||
|
||||
console.log("This is the npub: ${npub}");
|
||||
|
||||
|
||||
try {
|
||||
await SessionNpubbed.create({
|
||||
sessionNpubbedUuid: uuid.v7(),
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
const { Sequelize } = require('sequelize');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: './data/database.sqlite',
|
||||
dialect: 'postgres',
|
||||
host: 'postgres',
|
||||
port: 5432,
|
||||
database: process.env.POSTGRES_DB,
|
||||
username: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
define: {
|
||||
timestamps: false,
|
||||
freezeTableName: true
|
||||
},
|
||||
});
|
||||
|
||||
sequelize.sync().then(() => {
|
||||
console.log('Database synced');
|
||||
}).catch(err => {
|
||||
console.error('Error syncing the database:', err);
|
||||
});
|
||||
|
||||
module.exports = sequelize;
|
||||
Loading…
Add table
Add a link
Reference in a new issue