Skip to content

[Store] Documents might contain stale values after update #1472

@Merkur39

Description

@Merkur39

Today, documents in the Store are updated in this way:

const merged = {
  ...prevDocument,
  ...nextDocument
}

if (prevDocument.relationships || nextDocument.relationships) {
  merged.relationships = {
    ...prevDocument.relationships,
    ...nextDocument.relationships
  }
}

NB: in an object literal, the spread syntax enumerates the properties of an object and adds the key-value pairs to the object being created. But at the first level*

This approach allows you to update the document in the Store without necessarily having to pass the whole document to it (nextDocument), but poses a problem when you want to delete an attribute at the second level (or at the second level of relationships).

This change was made during this PR: #342

  1. We'll have to see why this problem has been corrected here and not elsewhere.
  2. We probably shouldn't have a spread, and replace the Store document with the new one. But we need to make sure we always have the full document in nextDocument.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdiscussionDiscuss about a particular subject to take a decision

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions