Consider the following relation:
Contact:
id
name
EntityContact
id
contactId
Notice in the following Contact Model I have a custom setter for name
field and whenver I need to set value to this field I would expect it to be done through my custom name
setter function.
class Contact extends Model {
static get fields() {
return [
{ name: "name", dataSource: "name" },
];
}
set name(val) {
// performing some custom logic
this.set("name", val);
}
get name(val) {
return this.get("name");
}
}
I've following relation defined in EntityContact model class
class EntityContact extends Model {
static relations = {
contactRecord: {
foreignKey: "contactId",
foreignStore: "contactStore",
relatedCollectionName: "entityContacts",
}
}
// ... other fields definition not mentioned
}
The problem lies here when I try to set the nested field using the setter function of model expecting it that I would call my custom name
setter function but it doesn't.
entityContactStore.first.set("contactRecord.name", "XYZ")