@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
121 lines (109 loc) • 22.7 kB
Markdown
---
lang: en
title: 'API docs: typeorm.typeormmixin'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/extensions/typeorm
permalink: /doc/en/lb4/apidocs.typeorm.typeormmixin.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/typeorm](./typeorm.md) > [TypeOrmMixin](./typeorm.typeormmixin.md)
## TypeOrmMixin() function
<b>Signature:</b>
```typescript
export declare function TypeOrmMixin<T extends MixinTarget<Application>>(superClass: T): {
new (...args: any[]): {
connectionManager: ConnectionManager;
connection(connectionConfig: ConnectionOptions): loopbackContext.Binding<Connection>;
migrateSchema(): Promise<void>;
readonly options: loopbackContext.ApplicationConfig;
readonly state: string;
controller: <T_1>(controllerCtor: loopbackContext.ControllerClass<T_1>, nameOrOptions?: string | loopbackContext.BindingFromClassOptions | undefined) => loopbackContext.Binding<T_1>;
server: <T_2 extends loopbackContext.Server>(ctor: loopbackContext.Constructor<T_2>, nameOrOptions?: string | loopbackContext.BindingFromClassOptions | undefined) => loopbackContext.Binding<T_2>;
servers: <T_3 extends loopbackContext.Server>(ctors: loopbackContext.Constructor<T_3>[]) => loopbackContext.Binding<any>[];
getServer: <T_4 extends loopbackContext.Server>(target: string | loopbackContext.Constructor<T_4>) => Promise<T_4>;
init: () => Promise<void>;
onInit: (fn: () => loopbackContext.ValueOrPromise<void>) => loopbackContext.Binding<loopbackContext.LifeCycleObserver>;
start: () => Promise<void>;
onStart: (fn: () => loopbackContext.ValueOrPromise<void>) => loopbackContext.Binding<loopbackContext.LifeCycleObserver>;
stop: () => Promise<void>;
onStop: (fn: () => loopbackContext.ValueOrPromise<void>) => loopbackContext.Binding<loopbackContext.LifeCycleObserver>;
component: <T_5 extends loopbackContext.Component = loopbackContext.Component>(componentCtor: loopbackContext.Constructor<T_5>, nameOrOptions?: string | loopbackContext.BindingFromClassOptions | undefined) => loopbackContext.Binding<T_5>;
setMetadata: (metadata: loopbackContext.ApplicationMetadata) => void;
lifeCycleObserver: <T_6 extends loopbackContext.LifeCycleObserver>(ctor: loopbackContext.Constructor<T_6>, nameOrOptions?: string | loopbackContext.BindingFromClassOptions | undefined) => loopbackContext.Binding<T_6>;
service: <S>(cls: loopbackContext.ServiceOrProviderClass<S>, nameOrOptions?: string | loopbackContext.ServiceOptions | undefined) => loopbackContext.Binding<S>;
interceptor: (interceptor: loopbackContext.Interceptor | loopbackContext.Constructor<loopbackContext.Provider<loopbackContext.Interceptor>>, nameOrOptions?: string | loopbackContext.InterceptorBindingOptions | undefined) => loopbackContext.Binding<loopbackContext.Interceptor>;
readonly name: string;
readonly subscriptionManager: loopbackContext.ContextSubscriptionManager;
scope: loopbackContext.BindingScope;
readonly parent: loopbackContext.Context | undefined;
emitEvent: <T_7 extends loopbackContext.ContextEvent>(type: string, event: T_7) => void;
emitError: (err: unknown) => void;
bind: <ValueType = any>(key: loopbackContext.BindingAddress<ValueType>) => loopbackContext.Binding<ValueType>;
add: (binding: loopbackContext.Binding<unknown>) => loopbackContext.Application;
configure: <ConfigValueType = any>(key?: loopbackContext.BindingAddress<unknown> | undefined) => loopbackContext.Binding<ConfigValueType>;
getConfigAsValueOrPromise: <ConfigValueType_1>(key: loopbackContext.BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => loopbackContext.ValueOrPromise<ConfigValueType_1 | undefined>;
getConfig: <ConfigValueType_2>(key: loopbackContext.BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
getConfigSync: <ConfigValueType_3>(key: loopbackContext.BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
unbind: (key: loopbackContext.BindingAddress<unknown>) => boolean;
subscribe: (observer: loopbackContext.ContextEventObserver) => loopbackContext.Subscription;
unsubscribe: (observer: loopbackContext.ContextEventObserver) => boolean;
close: () => void;
isSubscribed: (observer: loopbackContext.ContextObserver) => boolean;
createView: <T_8 = unknown>(filter: loopbackContext.BindingFilter, comparator?: loopbackContext.BindingComparator | undefined, options?: Omit<loopbackContext.ResolutionOptions, "session"> | undefined) => loopbackContext.ContextView<T_8>;
contains: (key: loopbackContext.BindingAddress<unknown>) => boolean;
isBound: (key: loopbackContext.BindingAddress<unknown>) => boolean;
getOwnerContext: (keyOrBinding: loopbackContext.BindingAddress<unknown> | Readonly<loopbackContext.Binding<unknown>>) => loopbackContext.Context | undefined;
getScopedContext: (scope: loopbackContext.BindingScope.APPLICATION | loopbackContext.BindingScope.SERVER | loopbackContext.BindingScope.REQUEST) => loopbackContext.Context | undefined;
getResolutionContext: (binding: Readonly<loopbackContext.Binding<unknown>>) => loopbackContext.Context | undefined;
isVisibleTo: (ctx: loopbackContext.Context) => boolean;
find: <ValueType_1 = any>(pattern?: string | RegExp | loopbackContext.BindingFilter | undefined) => Readonly<loopbackContext.Binding<ValueType_1>>[];
findByTag: <ValueType_2 = any>(tagFilter: RegExp | loopbackContext.BindingTag) => Readonly<loopbackContext.Binding<ValueType_2>>[];
get: {
<ValueType_3>(keyWithPath: loopbackContext.BindingAddress<ValueType_3>, session?: loopbackContext.ResolutionSession | undefined): Promise<ValueType_3>;
<ValueType_4>(keyWithPath: loopbackContext.BindingAddress<ValueType_4>, options: loopbackContext.ResolutionOptions): Promise<ValueType_4 | undefined>;
};
getSync: {
<ValueType_5>(keyWithPath: loopbackContext.BindingAddress<ValueType_5>, session?: loopbackContext.ResolutionSession | undefined): ValueType_5;
<ValueType_6>(keyWithPath: loopbackContext.BindingAddress<ValueType_6>, options?: loopbackContext.ResolutionOptions | undefined): ValueType_6 | undefined;
};
getBinding: {
<ValueType_7 = any>(key: loopbackContext.BindingAddress<ValueType_7>): loopbackContext.Binding<ValueType_7>;
<ValueType_8>(key: loopbackContext.BindingAddress<ValueType_8>, options?: {
optional?: boolean | undefined;
} | undefined): loopbackContext.Binding<ValueType_8> | undefined;
};
findOrCreateBinding: <T_9>(key: loopbackContext.BindingAddress<T_9>, policy?: loopbackContext.BindingCreationPolicy | undefined) => loopbackContext.Binding<T_9>;
getValueOrPromise: <ValueType_9>(keyWithPath: loopbackContext.BindingAddress<ValueType_9>, optionsOrSession?: loopbackContext.ResolutionOptionsOrSession | undefined) => loopbackContext.ValueOrPromise<ValueType_9 | undefined>;
toJSON: () => loopbackContext.JSONObject;
inspect: (options?: loopbackContext.ContextInspectOptions | undefined) => loopbackContext.JSONObject;
on: {
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): loopbackContext.Application;
(event: string | symbol, listener: (...args: any[]) => void): loopbackContext.Application;
};
once: {
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): loopbackContext.Application;
(event: string | symbol, listener: (...args: any[]) => void): loopbackContext.Application;
};
addListener: (event: string | symbol, listener: (...args: any[]) => void) => loopbackContext.Application;
removeListener: (event: string | symbol, listener: (...args: any[]) => void) => loopbackContext.Application;
off: (event: string | symbol, listener: (...args: any[]) => void) => loopbackContext.Application;
removeAllListeners: (event?: string | symbol | undefined) => loopbackContext.Application;
setMaxListeners: (n: number) => loopbackContext.Application;
getMaxListeners: () => number;
listeners: (event: string | symbol) => Function[];
rawListeners: (event: string | symbol) => Function[];
emit: (event: string | symbol, ...args: any[]) => boolean;
listenerCount: (type: string | symbol) => number;
prependListener: (event: string | symbol, listener: (...args: any[]) => void) => loopbackContext.Application;
prependOnceListener: (event: string | symbol, listener: (...args: any[]) => void) => loopbackContext.Application;
eventNames: () => (string | symbol)[];
};
} & T;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| superClass | T | |
<b>Returns:</b>
{ new (...args: any\[\]): { connectionManager: ConnectionManager; connection(connectionConfig: ConnectionOptions): loopbackContext.[Binding](./context.binding.md)<!-- --><Connection>; migrateSchema(): Promise<void>; readonly options: loopbackContext.[ApplicationConfig](./core.applicationconfig.md)<!-- -->; readonly state: string; controller: <T\_1>(controllerCtor: loopbackContext.[ControllerClass](./core.controllerclass.md)<!-- --><T\_1>, nameOrOptions?: string \| loopbackContext.[BindingFromClassOptions](./context.bindingfromclassoptions.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><T\_1>; server: <T\_2 extends loopbackContext.[Server](./core.server.md)<!-- -->>(ctor: loopbackContext.[Constructor](./context.constructor.md)<!-- --><T\_2>, nameOrOptions?: string \| loopbackContext.[BindingFromClassOptions](./context.bindingfromclassoptions.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><T\_2>; servers: <T\_3 extends loopbackContext.[Server](./core.server.md)<!-- -->>(ctors: loopbackContext.[Constructor](./context.constructor.md)<!-- --><T\_3>\[\]) => loopbackContext.[Binding](./context.binding.md)<!-- --><any>\[\]; getServer: <T\_4 extends loopbackContext.[Server](./core.server.md)<!-- -->>(target: string \| loopbackContext.[Constructor](./context.constructor.md)<!-- --><T\_4>) => Promise<T\_4>; init: () => Promise<void>; onInit: (fn: () => loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- --><void>) => loopbackContext.[Binding](./context.binding.md)<!-- --><loopbackContext.[LifeCycleObserver](./core.lifecycleobserver.md)<!-- -->>; start: () => Promise<void>; onStart: (fn: () => loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- --><void>) => loopbackContext.[Binding](./context.binding.md)<!-- --><loopbackContext.[LifeCycleObserver](./core.lifecycleobserver.md)<!-- -->>; stop: () => Promise<void>; onStop: (fn: () => loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- --><void>) => loopbackContext.[Binding](./context.binding.md)<!-- --><loopbackContext.[LifeCycleObserver](./core.lifecycleobserver.md)<!-- -->>; component: <T\_5 extends loopbackContext.[Component](./core.component.md) = loopbackContext.[Component](./core.component.md)<!-- -->>(componentCtor: loopbackContext.[Constructor](./context.constructor.md)<!-- --><T\_5>, nameOrOptions?: string \| loopbackContext.[BindingFromClassOptions](./context.bindingfromclassoptions.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><T\_5>; setMetadata: (metadata: loopbackContext.[ApplicationMetadata](./core.applicationmetadata.md)<!-- -->) => void; lifeCycleObserver: <T\_6 extends loopbackContext.[LifeCycleObserver](./core.lifecycleobserver.md)<!-- -->>(ctor: loopbackContext.[Constructor](./context.constructor.md)<!-- --><T\_6>, nameOrOptions?: string \| loopbackContext.[BindingFromClassOptions](./context.bindingfromclassoptions.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><T\_6>; service: <S>(cls: loopbackContext.[ServiceOrProviderClass](./core.serviceorproviderclass.md)<!-- --><S>, nameOrOptions?: string \| loopbackContext.[ServiceOptions](./core.serviceoptions.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><S>; interceptor: (interceptor: loopbackContext.[Interceptor](./context.interceptor.md) \| loopbackContext.[Constructor](./context.constructor.md)<!-- --><loopbackContext.[Provider](./context.provider.md)<!-- --><loopbackContext.[Interceptor](./context.interceptor.md)<!-- -->>>, nameOrOptions?: string \| loopbackContext.[InterceptorBindingOptions](./context.interceptorbindingoptions.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><loopbackContext.[Interceptor](./context.interceptor.md)<!-- -->>; readonly name: string; readonly subscriptionManager: loopbackContext.[ContextSubscriptionManager](./context.contextsubscriptionmanager.md)<!-- -->; scope: loopbackContext.[BindingScope](./context.bindingscope.md)<!-- -->; readonly parent: loopbackContext.[Context](./context.context.md) \| undefined; emitEvent: <T\_7 extends loopbackContext.[ContextEvent](./context.contextevent.md)<!-- -->>(type: string, event: T\_7) => void; emitError: (err: unknown) => void; bind: <ValueType = any>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType>) => loopbackContext.[Binding](./context.binding.md)<!-- --><ValueType>; add: (binding: loopbackContext.[Binding](./context.binding.md)<!-- --><unknown>) => loopbackContext.[Application](./core.application.md)<!-- -->; configure: <ConfigValueType = any>(key?: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown> \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><ConfigValueType>; getConfigAsValueOrPromise: <ConfigValueType\_1>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown>, propertyPath?: string \| undefined, resolutionOptions?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined) => loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- --><ConfigValueType\_1 \| undefined>; getConfig: <ConfigValueType\_2>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown>, propertyPath?: string \| undefined, resolutionOptions?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined) => Promise<ConfigValueType\_2 \| undefined>; getConfigSync: <ConfigValueType\_3>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown>, propertyPath?: string \| undefined, resolutionOptions?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined) => ConfigValueType\_3 \| undefined; unbind: (key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown>) => boolean; subscribe: (observer: loopbackContext.[ContextEventObserver](./context.contexteventobserver.md)<!-- -->) => loopbackContext.[Subscription](./context.subscription.md)<!-- -->; unsubscribe: (observer: loopbackContext.[ContextEventObserver](./context.contexteventobserver.md)<!-- -->) => boolean; close: () => void; isSubscribed: (observer: loopbackContext.[ContextObserver](./context.contextobserver.md)<!-- -->) => boolean; createView: <T\_8 = unknown>(filter: loopbackContext.[BindingFilter](./context.bindingfilter.md)<!-- -->, comparator?: loopbackContext.[BindingComparator](./context.bindingcomparator.md) \| undefined, options?: Omit<loopbackContext.[ResolutionOptions](./context.resolutionoptions.md)<!-- -->, "session"> \| undefined) => loopbackContext.[ContextView](./context.contextview.md)<!-- --><T\_8>; contains: (key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown>) => boolean; isBound: (key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown>) => boolean; getOwnerContext: (keyOrBinding: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><unknown> \| Readonly<loopbackContext.[Binding](./context.binding.md)<!-- --><unknown>>) => loopbackContext.[Context](./context.context.md) \| undefined; getScopedContext: (scope: loopbackContext.[BindingScope.APPLICATION](./context.bindingscope.md) \| loopbackContext.[BindingScope.SERVER](./context.bindingscope.md) \| loopbackContext.[BindingScope.REQUEST](./context.bindingscope.md)<!-- -->) => loopbackContext.[Context](./context.context.md) \| undefined; getResolutionContext: (binding: Readonly<loopbackContext.[Binding](./context.binding.md)<!-- --><unknown>>) => loopbackContext.[Context](./context.context.md) \| undefined; isVisibleTo: (ctx: loopbackContext.[Context](./context.context.md)<!-- -->) => boolean; find: <ValueType\_1 = any>(pattern?: string \| RegExp \| loopbackContext.[BindingFilter](./context.bindingfilter.md) \| undefined) => Readonly<loopbackContext.[Binding](./context.binding.md)<!-- --><ValueType\_1>>\[\]; findByTag: <ValueType\_2 = any>(tagFilter: RegExp \| loopbackContext.[BindingTag](./context.bindingtag.md)<!-- -->) => Readonly<loopbackContext.[Binding](./context.binding.md)<!-- --><ValueType\_2>>\[\]; get: { <ValueType\_3>(keyWithPath: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_3>, session?: loopbackContext.[ResolutionSession](./context.resolutionsession.md) \| undefined): Promise<ValueType\_3>; <ValueType\_4>(keyWithPath: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_4>, options: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md)<!-- -->): Promise<ValueType\_4 \| undefined>; }; getSync: { <ValueType\_5>(keyWithPath: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_5>, session?: loopbackContext.[ResolutionSession](./context.resolutionsession.md) \| undefined): ValueType\_5; <ValueType\_6>(keyWithPath: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_6>, options?: loopbackContext.[ResolutionOptions](./context.resolutionoptions.md) \| undefined): ValueType\_6 \| undefined; }; getBinding: { <ValueType\_7 = any>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_7>): loopbackContext.[Binding](./context.binding.md)<!-- --><ValueType\_7>; <ValueType\_8>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_8>, options?: { optional?: boolean \| undefined; } \| undefined): loopbackContext.[Binding](./context.binding.md)<!-- --><ValueType\_8> \| undefined; }; findOrCreateBinding: <T\_9>(key: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><T\_9>, policy?: loopbackContext.[BindingCreationPolicy](./context.bindingcreationpolicy.md) \| undefined) => loopbackContext.[Binding](./context.binding.md)<!-- --><T\_9>; getValueOrPromise: <ValueType\_9>(keyWithPath: loopbackContext.[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType\_9>, optionsOrSession?: loopbackContext.[ResolutionOptionsOrSession](./context.resolutionoptionsorsession.md) \| undefined) => loopbackContext.[ValueOrPromise](./context.valueorpromise.md)<!-- --><ValueType\_9 \| undefined>; toJSON: () => loopbackContext.[JSONObject](./context.jsonobject.md)<!-- -->; inspect: (options?: loopbackContext.[ContextInspectOptions](./context.contextinspectoptions.md) \| undefined) => loopbackContext.[JSONObject](./context.jsonobject.md)<!-- -->; on: { (eventName: "bind" \| "unbind", listener: loopbackContext.[ContextEventListener](./context.contexteventlistener.md)<!-- -->): loopbackContext.[Application](./core.application.md)<!-- -->; (event: string \| symbol, listener: (...args: any\[\]) => void): loopbackContext.[Application](./core.application.md)<!-- -->; }; once: { (eventName: "bind" \| "unbind", listener: loopbackContext.[ContextEventListener](./context.contexteventlistener.md)<!-- -->): loopbackContext.[Application](./core.application.md)<!-- -->; (event: string \| symbol, listener: (...args: any\[\]) => void): loopbackContext.[Application](./core.application.md)<!-- -->; }; addListener: (event: string \| symbol, listener: (...args: any\[\]) => void) => loopbackContext.[Application](./core.application.md)<!-- -->; removeListener: (event: string \| symbol, listener: (...args: any\[\]) => void) => loopbackContext.[Application](./core.application.md)<!-- -->; off: (event: string \| symbol, listener: (...args: any\[\]) => void) => loopbackContext.[Application](./core.application.md)<!-- -->; removeAllListeners: (event?: string \| symbol \| undefined) => loopbackContext.[Application](./core.application.md)<!-- -->; setMaxListeners: (n: number) => loopbackContext.[Application](./core.application.md)<!-- -->; getMaxListeners: () => number; listeners: (event: string \| symbol) => Function\[\]; rawListeners: (event: string \| symbol) => Function\[\]; emit: (event: string \| symbol, ...args: any\[\]) => boolean; listenerCount: (type: string \| symbol) => number; prependListener: (event: string \| symbol, listener: (...args: any\[\]) => void) => loopbackContext.[Application](./core.application.md)<!-- -->; prependOnceListener: (event: string \| symbol, listener: (...args: any\[\]) => void) => loopbackContext.[Application](./core.application.md)<!-- -->; eventNames: () => (string \| symbol)\[\]; }; } & T