add cohort and filter models
This commit is contained in:
27
server/api/models/cohort.js
Normal file
27
server/api/models/cohort.js
Normal 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
|
||||||
31
server/api/models/filter.js
Normal file
31
server/api/models/filter.js
Normal 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
|
||||||
Reference in New Issue
Block a user