json-api-server
Version:
A NodeJS framework implementing json:api
26 lines (22 loc) • 511 B
JavaScript
import Sequelize from 'sequelize'
const defaultOptions = {
pool: {
max: 5,
min: 0,
idle: 10000
}
}
export default class Database {
constructor(name, options = {}) {
const mergedOptions = Object.assign({}, defaultOptions, options)
this.sequelize = new Sequelize(
name,
mergedOptions.username,
mergedOptions.password,
mergedOptions
)
}
defineModel(type, attributes) {
return this.sequelize.define(type, attributes, { freezeTableName: true })
}
}