This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/server/models/Event.js

54 lines
899 B
JavaScript

// @flow
import { DataTypes, sequelize } from '../sequelize';
const Event = sequelize.define('event', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
name: DataTypes.STRING,
data: DataTypes.JSONB,
userId: {
type: 'UUID',
allowNull: true,
references: {
model: 'users',
},
},
collectionId: {
type: 'UUID',
allowNull: true,
references: {
model: 'collections',
},
},
teamId: {
type: 'UUID',
allowNull: true,
references: {
model: 'teams',
},
},
});
Event.associate = models => {
Event.belongsTo(models.User, {
as: 'user',
foreignKey: 'userId',
});
Event.belongsTo(models.Collection, {
as: 'collection',
foreignKey: 'collectionId',
});
Event.belongsTo(models.Team, {
as: 'team',
foreignKey: 'teamId',
});
};
export default Event;