UNPKG

@loopback/docs

Version:
63 lines (46 loc) 2.31 kB
--- lang: en title: 'API docs: repository.repositorymixin' keywords: LoopBack 4.0, LoopBack 4 sidebar: lb4_sidebar permalink: /doc/en/lb4/apidocs.repository.repositorymixin.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [RepositoryMixin](./repository.repositorymixin.md) ## RepositoryMixin() function A mixin class for Application that creates a .repository() function to register a repository automatically. Also overrides component function to allow it to register repositories automatically. <b>Signature:</b> ```typescript export declare function RepositoryMixin<T extends Class<any>>(superClass: T): { new (...args: any[]): { [x: string]: any; repository<R extends Repository<any>>(repoClass: Class<R>, name?: string | undefined): Binding<R>; getRepository<R extends Repository<any>>(repo: Class<R>): Promise<R>; dataSource<D extends juggler.DataSource>(dataSource: D | Class<D>, name?: string | undefined): Binding<D>; component(component: Class<unknown>, name?: string | undefined): void; mountComponentRepositories(component: Class<unknown>): void; migrateSchema(options?: SchemaMigrationOptions): Promise<void>; }; } & T; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | superClass | <code>T</code> | | <b>Returns:</b> `{ new (...args: any[]): { [x: string]: any; repository<R extends Repository<any>>(repoClass: Class<R>, name?: string | undefined): Binding<R>; getRepository<R extends Repository<any>>(repo: Class<R>): Promise<R>; dataSource<D extends juggler.DataSource>(dataSource: D | Class<D>, name?: string | undefined): Binding<D>; component(component: Class<unknown>, name?: string | undefined): void; mountComponentRepositories(component: Class<unknown>): void; migrateSchema(options?: SchemaMigrationOptions): Promise<void>; }; } & T` ## Example ```ts class MyApplication extends RepositoryMixin(Application) {} ``` Please note: the members in the mixin function are documented in a dummy class called <a href="#RepositoryMixinDoc">RepositoryMixinDoc</a>