跳到主要内容

RxDBChangeEntityMetadataResolver

type RxDBChangeEntityMetadataResolver = (entity, namespace) => EntityMetadata | undefined;

Defined in: packages/rxdb/src/system/change-codec.ts:212

反查对端实体元数据的回调。

Parameters​

ParameterTypeDescription
entitystring对端实体名
namespacestring对端实体所在命名空间

Returns​

EntityMetadata | undefined

找到则返回元数据,未在本进程注册时返回 undefined

Remarks​

只在一种情况下被用到:patch 里的 key 是外键列,而本实体的 propertyMap 里 没有它(多对多中间表只声明本侧外键是典型场景)。这时列的真实类型写在对端 的 id 上,不反查就会把一个 bigint 外键当普通值直接落 JSON。

具名导出是为了让 @aiao/rxdb-plugin-working-tree 的工作树 patch codec 与各适配器的 encryptionContext.resolveEntityMetadata 引用同一个类型,而不是各自声明一份 结构相同的匿名签名——结构相同的类型改起来不会互相报错,改漂了也没人知道。