mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
Convert first files to TypeScript
Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
0d788e0aec
commit
f6eec0ce90
7 changed files with 301 additions and 294 deletions
44
lib/models/author.ts
Normal file
44
lib/models/author.ts
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue