2020-01-14 23:26:39 +01:00
|
|
|
const Sequelize = require('sequelize');
|
|
|
|
|
|
|
|
module.exports = sequelize => sequelize.define('BookReference', {
|
|
|
|
id: {
|
|
|
|
type: Sequelize.INTEGER,
|
|
|
|
primaryKey: true,
|
|
|
|
autoIncrement: true,
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
allowNull: false,
|
|
|
|
comment: 'The description is attempted to be made up of the type of work and the author',
|
|
|
|
},
|
|
|
|
sources: {
|
|
|
|
type: Sequelize.JSON,
|
|
|
|
allowNull: false,
|
2020-02-06 17:31:47 +01:00
|
|
|
defaultValue: {},
|
|
|
|
comment: 'A JSON object with each key a source name and value a source id',
|
2020-01-14 23:26:39 +01:00
|
|
|
},
|
|
|
|
covers: {
|
|
|
|
type: Sequelize.JSON,
|
|
|
|
allowNull: false,
|
|
|
|
defaultValue: [],
|
|
|
|
comment: 'A JSON array with each element being an object with image url <STRING> and source id <STRING>',
|
|
|
|
},
|
2020-02-06 17:31:47 +01:00
|
|
|
locale: {
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
allowNull: false,
|
|
|
|
defaultValue: 'en',
|
|
|
|
comment: 'A basic locale string',
|
|
|
|
},
|
2020-01-14 23:26:39 +01:00
|
|
|
}, {
|
|
|
|
timestamps: false,
|
|
|
|
indexes: [
|
|
|
|
{
|
|
|
|
unique: true,
|
|
|
|
fields: ['name', 'description'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: ['name'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: ['description'],
|
|
|
|
},
|
2020-02-06 17:31:47 +01:00
|
|
|
{
|
|
|
|
fields: ['locale'],
|
|
|
|
},
|
2020-01-14 23:26:39 +01:00
|
|
|
],
|
|
|
|
});
|