isRemoteNewer()
function isRemoteNewer(
remoteUpdatedAt,
localUpdatedAt,
context
): boolean;
Defined in: packages/rxdb/src/repository/updated-at.utils.ts:47
判定远端记录是否比本地新。
Parameters
| Parameter | Type | Description |
|---|---|---|
remoteUpdatedAt | string | 远端时间串 |
localUpdatedAt | string | 本地时间串 |
context | string | 报错时用于定位的上下文 |
Returns
boolean
远端严格更新时为 true
Throws
TypeError 任一侧解析不出时间点时抛出。
Remarks
必须比时间点,不能比字符串字典序。字典序要求两侧格式完全一致,而实际来源并不一致:
本地写的是 .000Z,Supabase 给 +00:00 偏移,多数 HTTP 后端给不带毫秒的 Z。
'…:00Z' > '…:00.000Z' 在字典序下为真('Z' 的码位大于 '.'),于是同一个时刻
被判成过期 —— 每次同步全量重拉,永不收敛。反向的写法(local >= remote)则相反,
会把新鲜判成过期,症状一样。