mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
Create custom field table and assocs
This commit is contained in:
@@ -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",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
backend/src/models/ContactCustomField.js
Normal file
26
backend/src/models/ContactCustomField.js
Normal 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;
|
||||
Reference in New Issue
Block a user