* Global search scaffold * Add search preview text * Add generic fallback for preview text in search * fixup! Add generic fallback for preview text in search * Add more tweaks * fixup! Add more tweaks * Fix an issue with criteria * fixup! Fix an issue with criteria * fixup! fixup! Fix an issue with criteria * fixup! fixup! fixup! Fix an issue with criteria * Fix an issue with priority filter * fixup! Fix an issue with priority filter * Add sortable pins * fixup! Add sortable pins * Make options collapsed by default * Tweak UI * Add tests * Add translations * Add more translations * fixup! Add more translations * Add minor tweaks
74 lines
2 KiB
JavaScript
74 lines
2 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { uid } = require('../utils/uid');
|
|
|
|
module.exports = (sequelize) => {
|
|
const View = sequelize.define(
|
|
'View',
|
|
{
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
},
|
|
uid: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
unique: true,
|
|
defaultValue: uid,
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
user_id: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'users',
|
|
key: 'id',
|
|
},
|
|
},
|
|
search_query: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true,
|
|
},
|
|
filters: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
get() {
|
|
const rawValue = this.getDataValue('filters');
|
|
return rawValue ? JSON.parse(rawValue) : [];
|
|
},
|
|
set(value) {
|
|
this.setDataValue('filters', JSON.stringify(value));
|
|
},
|
|
},
|
|
priority: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true,
|
|
},
|
|
due: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true,
|
|
},
|
|
is_pinned: {
|
|
type: DataTypes.BOOLEAN,
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
},
|
|
},
|
|
{
|
|
tableName: 'views',
|
|
indexes: [
|
|
{
|
|
fields: ['user_id'],
|
|
},
|
|
{
|
|
fields: ['user_id', 'is_pinned'],
|
|
},
|
|
],
|
|
}
|
|
);
|
|
|
|
return View;
|
|
};
|