UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

54 lines (34 loc) 1.45 kB
--- lang: en title: 'API docs: repository.repositorymixindoc.datasource' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/repository permalink: /doc/en/lb4/apidocs.repository.repositorymixindoc.datasource.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [RepositoryMixinDoc](./repository.repositorymixindoc.md) &gt; [dataSource](./repository.repositorymixindoc.datasource.md) ## RepositoryMixinDoc.dataSource() method Add the dataSource to this application. <b>Signature:</b> ```typescript dataSource(dataSource: Class<juggler.DataSource> | juggler.DataSource, name?: string): Binding; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | dataSource | [Class](./repository.class.md)<!-- -->&lt;juggler.DataSource&gt; \| juggler.DataSource | The dataSource to add. | | name | string | The binding name of the datasource; defaults to dataSource.name | <b>Returns:</b> [Binding](./context.binding.md) ## Example ```ts const ds: juggler.DataSource = new juggler.DataSource({ name: 'db', connector: 'memory', }); app.dataSource(ds); // The datasource can be injected with constructor(@inject('datasources.db') dataSource: DataSourceType) { } ```