mirror of
https://github.com/docker-training/node-bulletin-board.git
synced 2025-12-15 07:16:43 +08:00
Add v4, with proxy, app and db
This commit is contained in:
34
bulletin-board-app/backend/db.js
Normal file
34
bulletin-board-app/backend/db.js
Normal file
@@ -0,0 +1,34 @@
|
||||
var Sequelize = require('sequelize');
|
||||
var username = 'sa';
|
||||
var password = 'DockerCon!!!';
|
||||
var host = 'bb-db';
|
||||
var dbName = 'BulletinBoard';
|
||||
|
||||
var sequelize = new Sequelize(dbName, username, password, {
|
||||
dialect: 'mssql',
|
||||
host: host,
|
||||
port: 1433,
|
||||
dialectOptions: {
|
||||
requestTimeout: 30000
|
||||
}
|
||||
});
|
||||
|
||||
sequelize
|
||||
.authenticate()
|
||||
.then(() => {
|
||||
console.log('Successful connection to SQL Server.');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('** SQL Server connection failed: ', err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
var Event = sequelize.define('event', {
|
||||
title: Sequelize.STRING,
|
||||
detail: Sequelize.STRING,
|
||||
date: Sequelize.DATE
|
||||
});
|
||||
|
||||
Event.sync();
|
||||
|
||||
exports.Events = Event;
|
||||
Reference in New Issue
Block a user