Convert first files to TypeScript

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2019-11-23 21:34:31 +01:00 committed by Sheogorath
parent 0d788e0aec
commit f6eec0ce90
No known key found for this signature in database
GPG key ID: C9B1C80737B9CE18
7 changed files with 301 additions and 294 deletions

44
lib/models/author.ts Normal file
View file

@ -0,0 +1,44 @@
// external modules
import {DataTypes} from 'sequelize';
function createAutorModel(sequelize) {
const Author = sequelize.define('Author', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
color: {
type: DataTypes.STRING
}
}, {
indexes: [
{
unique: true,
fields: ['noteId', 'userId']
}
]
});
Author.associate = function (models) {
Author.belongsTo(models.Note, {
foreignKey: 'noteId',
as: 'note',
constraints: false,
onDelete: 'CASCADE',
hooks: true
});
Author.belongsTo(models.User, {
foreignKey: 'userId',
as: 'user',
constraints: false,
onDelete: 'CASCADE',
hooks: true
})
};
return Author
}
export = createAutorModel