squashRecordDiffs
See source codeCombines multiple RecordsDiff objects into a single consolidated diff. This function intelligently merges changes, handling cases where the same record is modified multiple times across different diffs. For example, if a record is added in one diff and then updated in another, the result will show it as added with the final state.
function squashRecordDiffs<T extends UnknownRecord>(
  diffs: RecordsDiff<T>[],
  options?: {
    mutateFirstDiff?: boolean
  }
): RecordsDiff<T>Example
const diff1: RecordsDiff<Book> = {
  added: { 'book:1': { id: 'book:1', title: 'New Book' } },
  updated: {},
  removed: {},
}
const diff2: RecordsDiff<Book> = {
  added: {},
  updated: {
    'book:1': [
      { id: 'book:1', title: 'New Book' },
      { id: 'book:1', title: 'Updated Title' },
    ],
  },
  removed: {},
}
const squashed = squashRecordDiffs([diff1, diff2])
// Result: {
//   added: { 'book:1': { id: 'book:1', title: 'Updated Title' } },
//   updated: {},
//   removed: {}
// }Parameters
| Name | Description | 
|---|---|
  | An array of diffs to combine into a single diff  | 
  | Configuration options for the squashing operation 
  | 
Returns
RecordsDiff<T>A single diff that represents the cumulative effect of all input diffs
Prev
reverseRecordsDiffNext
useSync