Added Event model and logging to Collection
This commit is contained in:
53
server/models/Event.js
Normal file
53
server/models/Event.js
Normal file
@ -0,0 +1,53 @@
|
||||
// @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;
|
Reference in New Issue
Block a user