mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
add cohort and filter models
This commit is contained in:
parent
bc38dcfc9f
commit
833d859b5a
2 changed files with 58 additions and 0 deletions
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
|
Loading…
Reference in a new issue