跳到主要内容

RxDBRepositories

Defined in: packages/rxdb/src/rxdb-adapter.ts:900

已注册门面仓储的类型注册表

Remarks​

门面轴(@Entity({ repository: 'X' }) → getRepository(E) 拿到什么)的名字表。 核心只自带 Repository 一项(由 EntityManager 的构造函数登记到运行期), 插件包用 declare module '@aiao/rxdb' 把自己的门面合并进来,与核心那项同为一等公民 (TreeRepository 就来自 @aiao/rxdb-plugin-tree)。

与 RxDBAdapters 同一套模板,同一个禁忌:绝不能加索引签名。 一旦加上,keyof RxDBRepositories 就塌成 string,所有 declare module 静默失效。 「名字可以是任意字符串」这件事由 RxDBRepositoryName 的 (string & {}) 那一支承担。

值写成 typeof X(构造器类型)而非实例类型:三个门面的类型形参都无默认值, 实例类型在这里写不出来,而注册表要的本来就是「哪个类」。

Example​

declare module '@aiao/rxdb' {
interface RxDBRepositories {
GraphRepository: typeof GraphRepository;
}
}

Properties​

Repository​

Repository: typeof Repository;

Defined in: packages/rxdb/src/rxdb-adapter.ts:901