Skip to content

Problem with deep HasMany merge #1560

@Merkur39

Description

@Merkur39

In the example below, the setHasManyItem and updateHasManyItem helpers cannot be used to remove values from relationTypes.

{
  _id: 'contact0',
  name: 'Alice',
  relationships: {
    related: {
      data: [
        {
          _id: 'related0',
          metadata: {
            relationTypes: ['spouse', 'friend']
          }
        }
      ]
    }
  }
}

At issue are two merges here and there in setHasManyItem.

The documentation shows a manual approach.

We already got around the problem here cozy-contacts.

PS: Another subject, but we've encountered a similar problem with the cozy-client store.
Both approaches assume that the value passed as an argument is not up to date with the original document.
Maybe it would be a good idea to review the approach? 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions