@technove/typeorm-inject

This package provides @Inject support for TypeORM.

Usage no npm install needed!

<script type="module">
  import technoveTypeormInject from 'https://cdn.skypack.dev/@technove/typeorm-inject';
</script>

README

@technove/typeorm-inject

This package provides @Inject support for TypeORM.

Installation

yarn add @technove/typeorm-inject @technove/inject reflect-metadata

Or on npm:

npm install --save @technove/typeorm-inject @technove/inject reflect-metadata

Then at the top of your application's entry point, add the following line:

import "reflect-metadata";

To use the package, add the following line to your application before you create a connection:

import { createConnection, useContainer } from "typeorm";
import { globalContainer } from "@technove/inject";

/** Tell TypeORM to use the container provided by @technove/inject to resolve it's dependencies. */
useContainer(globalContainer);

And finally in your tsconfig.json, set experimentalDecorators and emitDecoratorMetadata to true.

Usage

This library is heavily based off of typeorm-typedi-extensions. The usage of the @InjectConnection(), @InjectManager(), and @InjectRepository() is the exact same. In the future we'll have the docs built out to show the usage of the decorators.

License

MIT