hedgedoc/lib/models/index.ts

30 lines
728 B
TypeScript
Raw Normal View History

import {Sequelize} from 'sequelize-typescript';
import {Author} from './author';
import {Note} from './note';
import {Revision} from './revision';
import {Temp} from './temp';
import {User} from './user';
const {cloneDeep} = require('lodash')
// core
var config = require('../config')
var logger = require('../logger')
var dbconfig = cloneDeep(config.db)
dbconfig.logging = config.debug ? (data) => {
logger.info(data)
} : false
export let sequelize: any = null;
2016-12-22 00:23:17 -05:00
2016-12-22 06:42:00 -05:00
// Heroku specific
if (config.dbURL) {
sequelize = new Sequelize(config.dbURL, dbconfig)
} else {
sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig)
}
sequelize.addModels([Author, Note, Revision, Temp, User]);