flushQueryCacheOutbox()
function flushQueryCacheOutbox(
rxdb,
namespace,
entity,
options?
): Promise<QueryCacheOutboxResult>;
Defined in: rxdb-plugin-sync/src/query-cache-outbox.ts:232
把某个 QueryCache 仓库积压的离线改动重放回远端。
Parameters
| Parameter | Type | Description |
|---|---|---|
rxdb | RxDB | RxDB 实例,用来取分支、本地/远端适配器与实体配置 |
namespace | string | 实体命名空间 |
entity | string | 实体名 |
options? | { conflictResolver?: ConflictResolver; } | 可选的冲突解决器;默认 LWWConflictResolver |
options.conflictResolver? | ConflictResolver | - |
Returns
Promise<QueryCacheOutboxResult>
本轮的重放结果
Throws
RxDBError 该仓库不存在,或它的 syncType 不是 'querycache'
Remarks
同一仓库上的并发调用会复用同一个在飞的 Promise(见 inflight)。
失败即整轮中止、水位线不推进:REST 没有批级原子性,也没有 per-change 的确认回执。
已经成功发出去的那几条因此会在下一轮被重发 —— 这与 pushRepository 在批次中途失败时
的暴露面相同。用一个哨兵值去写 RxDBChange.remoteId 能消除重发,但那个字段的语义是
「本地变更对应的远端 changelog 行」,REST 路径根本没有这个 id,写进去会让
pull-conflict-utils 与待推计数读到一个不存在的引用。
Example
const result = await flushQueryCacheOutbox(rxdb, 'public', 'Recipe');
if (result.failures.length === 0) {
console.log(`replayed ${result.replayed}, watermark → ${result.watermark}`);
}