diffMetadata()
function diffMetadata(remoteMetadata, localMetadata): DiffResult;
Defined in: packages/rxdb/src/repository/diff-metadata.ts:66
Compare remote metadata with local metadata to determine sync actions
Uses ISO 8601 timestamp comparison for freshness detection. All updatedAt values MUST be ISO 8601 strings (e.g., "2024-01-12T08:30:00.000Z"). Time complexity: O(n) where n = max(remote.length, local.size)
Parameters
| Parameter | Type | Description |
|---|---|---|
remoteMetadata | QueryCacheEntityMetadata[] | Metadata from remote adapter (id + updatedAt as ISO 8601) |
localMetadata | Map<string, string> | Map of id → updatedAt (ISO 8601) from local adapter |
Returns
DiffResult with categorized IDs
Example
const diff = diffMetadata(
[{ id: '1', updatedAt: '2024-01-02T00:00:00Z' }],
new Map([['1', '2024-01-01T00:00:00Z']])
);
// diff.staleIds = ['1'] - remote is newer
Remarks
- ISO 8601 strings are lexicographically comparable ("2024-01-02" > "2024-01-01")
- For non-ISO timestamps, convert to Date objects before calling this function
- Timezone information is preserved in ISO 8601 format