1
0
Fork 0
mirror of https://gitlab.com/Alamantus/Readlebee.git synced 2025-04-10 13:40:28 +02:00
Readlebee/server/sequelize/models/Shelf.js
Robbie Antenesse 071e1e6586 Update sequelize & DB setup:
- Split models & associations into their own files
- Update columns and requirements
- Create PermissionLevel model & add to relevant models
2020-01-14 15:47:44 -07:00

60 lines
No EOL
1.1 KiB
JavaScript

const Sequelize = require('sequelize');
module.exports = sequelize => sequelize.define('Shelf', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
userId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: sequelize.models.User,
key: 'id',
deferrable: Sequelize.Deferrable.INITIALLY_IMMEDIATE,
}
},
name: {
type: Sequelize.STRING,
allowNull: false,
validate: {
len: [1, 32],
},
},
permissionLevel: {
type: Sequelize.BOOLEAN,
allowNull: false,
references: {
model: sequelize.models.PermissionLevel,
key: 'id',
deferrable: Sequelize.Deferrable.INITIALLY_IMMEDIATE,
}
},
isDeletable: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true,
},
// Timestamps
createdAt: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.NOW,
},
}, {
indexes: [
{
fields: ['userId'],
},
{
fields: ['permissionLevel'],
},
],
});