Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Relation Field Does Not Call Custom Setter For Field #8890

Open
ghulamghousdev opened this issue Mar 26, 2024 · 0 comments
Open

Nested Relation Field Does Not Call Custom Setter For Field #8890

ghulamghousdev opened this issue Mar 26, 2024 · 0 comments
Labels
bug Something isn't working forum Issues from forum

Comments

@ghulamghousdev
Copy link
Member

Forum post

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")
@ghulamghousdev ghulamghousdev added bug Something isn't working forum Issues from forum labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum
Projects
None yet
Development

No branches or pull requests

1 participant