Create custom field table and assocs

This commit is contained in:
canove
2020-07-23 17:15:47 -03:00
parent c61ef7e732
commit b20ed4c8db
8 changed files with 134 additions and 5 deletions

View File

@@ -18,6 +18,10 @@ class Contact extends Sequelize.Model {
static associate(models) {
this.hasMany(models.Ticket, { foreignKey: "contactId" });
this.hasMany(models.ContactCustomField, {
foreignKey: "contactId",
as: "extraInfo",
});
}
}

View File

@@ -0,0 +1,26 @@
const Sequelize = require("sequelize");
class ContactCustomField extends Sequelize.Model {
static init(sequelize) {
super.init(
{
name: { type: Sequelize.STRING },
value: { type: Sequelize.STRING },
},
{
sequelize,
}
);
return this;
}
static associate(models) {
this.belongsTo(models.Contact, {
foreignKey: "contactId",
as: "extraInfo",
});
}
}
module.exports = ContactCustomField;