hedgedoc/lib/models/author.js
BoHong Li 5870d988b5 Use strict mode in all backend files
add ‘use strict’ in all backend file
2017-03-14 13:02:43 +08:00

38 lines
778 B
JavaScript

'use strict'
// external modules
var Sequelize = require('sequelize')
module.exports = function (sequelize, DataTypes) {
var Author = sequelize.define('Author', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
color: {
type: DataTypes.STRING
}
}, {
indexes: [
{
unique: true,
fields: ['noteId', 'userId']
}
],
classMethods: {
associate: function (models) {
Author.belongsTo(models.Note, {
foreignKey: 'noteId',
as: 'note',
constraints: false
})
Author.belongsTo(models.User, {
foreignKey: 'userId',
as: 'user',
constraints: false
})
}
}
})
return Author
}