1

I have a nested model like the following, where propertyArray is an array of objects defined in Model2, Model1 is the target of a 1 to 1 relationship, so I am accessing it from the source model repository of the relationship.

@model()
class Model2 {
  @property({
    type: 'string',
  })
  name?: string;

  @property({
    type: 'string',
  })
  value?: string;
}

@model({settings: {strict: false}})
export class Model1 extends Entity {
  @property({
    type: 'string',
    id: true,
    generated: true,
  })
  _id?: string;

  @property.array(Cookie)
  propertyArray: Model2[];
}

I am trying to update some of the objects inside the array by filtering by the name and value using a where filter with no results so far


this.SourceRepository.Model1(entityid).patch({Model2: {"name": "newname", "value": "newvalue"}}, {
    where: {
        arrayProperty: {and: [{name: 'existingvalue'}, {value: 'existingvalue'}]}
    }
});

PS: Sorry for any spelling or grammar errors, English is not my first language

Matias
  • 11
  • 1
  • Did you ever find an answer? I have been looking for a while, but I could only do it by accessing the dataSource directly in the repository. – Abhishek Tyagi Dec 03 '20 at 12:45

0 Answers0