synt_backend
Version:
Synt light-weight node backend service
42 lines (41 loc) • 1.16 kB
JavaScript
const { Model } = require("sequelize");
module.exports = (sequelize, DataTypes) => {
class Document extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
Document.belongsTo(models.VME);
Document.belongsToMany(models.User, { through: "DocumentUser" });
Document.belongsTo(models.DocumentType);
Document.hasMany(models.DocumentFile);
}
}
Document.init(
{
name: DataTypes.STRING,
visibility: DataTypes.ENUM("synt", "custom", "owners", "everyone"),
visibility_translation: {
type: DataTypes.VIRTUAL,
get() {
let translation_nl = {
synt: "Synt",
custom: "Aangepast",
owners: "Alle eigenaars",
everyone: "Iedereen",
};
return translation_nl[this.getDataValue("visibility")];
},
},
},
{
sequelize,
modelName: "Document",
}
);
return Document;
};
;