add cohort and filter models

This commit is contained in:
lesion 2022-05-20 12:34:36 +02:00
parent bc38dcfc9f
commit 833d859b5a
No known key found for this signature in database
GPG key ID: 352918250B012177
2 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,27 @@
const { Model, DataTypes } = require('sequelize')
const sequelize = require('./index').sequelize
class Cohort extends Model {}
Cohort.init({
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
name: {
type: DataTypes.STRING,
unique: true,
index: true,
allowNull: false
},
isActor: {
type: DataTypes.BOOLEAN
},
isTop: {
type: DataTypes.BOOLEAN
}
}, { sequelize, modelName: 'cohort', timestamps: false })
module.exports = Cohort

View file

@ -0,0 +1,31 @@
const { Model, DataTypes } = require('sequelize')
const sequelize = require('./index').sequelize
class Filter extends Model {}
Filter.init({
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
cohortId: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: 'cohorts',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'SET NULL'
},
tags: {
type: DataTypes.JSON,
},
places: {
type: DataTypes.JSON,
}
}, { sequelize, modelName: 'filter', timestamps: false })
module.exports = Filter