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
- We'll have to see why this problem has been corrected here and not elsewhere.
- 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.
Today, documents in the Store are updated in this way:
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 ofrelationships).This change was made during this PR: #342
nextDocument.