Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nest-dynamodb/typedorm
A DynamoDB module for Nest framework (node.js) using typeDorm library
https://github.com/nest-dynamodb/typedorm
aws dynamodb nestjs typedorm
Last synced: 2 months ago
JSON representation
A DynamoDB module for Nest framework (node.js) using typeDorm library
- Host: GitHub
- URL: https://github.com/nest-dynamodb/typedorm
- Owner: nest-dynamodb
- License: mit
- Created: 2023-02-23T05:48:59.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T19:55:40.000Z (2 months ago)
- Last Synced: 2024-10-29T21:46:16.104Z (2 months ago)
- Topics: aws, dynamodb, nestjs, typedorm
- Language: TypeScript
- Homepage:
- Size: 79.1 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A DynamoDB module for Nest framework (node.js) using typeDorm library### Installation
#### with npm
```sh
npm install --save @nest-dynamodb/typedorm
```#### with yarn
```sh
yarn add @nest-dynamodb/typedorm
```### How to use?
#### TypeDormModule.forRoot(options)
```ts
import { Module } from '@nestjs/common';
import { TypeDormModule } from '@nest-dynamodb/typedorm';
import { AppController } from './app.controller';
@Module({
imports: [
TypeDormModule.forRoot({
table,
entities: [],
documentClient: new DocumentClientV3(new DynamoDBClient({})),
name: instanceName
}),
],
controllers: [AppController],
})
export class AppModule {}
```#### TypeDormModule.forRootAsync(options)
```ts
import { Module } from '@nestjs/common';
import { TypeDormModule } from '@nest-dynamodb/typedorm';
import { AppController } from './app.controller';
@Module({
imports: [
TypeDormModule.forRootAsync({
// need another name here for dependency injection, @InjectTypeDorm(instanceName)
name: instanceName,
useFactory: async () => {
return {
table,
entities: [],
documentClient: new DocumentClientV3(new DynamoDBClient({})),
name: instanceName
}
},
}),
],
controllers: [AppController],
})
export class AppModule {}
```#### InjectTypeDorm(name?)
```ts
import { Controller, Get, } from '@nestjs/common';
import { InjectTypeDorm, TypeDormConnection } from '@nest-dynamodb/typedorm';
@Controller()
export class AppController {
constructor(
@InjectTypeDorm() private readonly connection: TypeDormConnection,
) {}
@Get()
async getHello() {
const item = await this.connection.entityManager.findOne(...);
return { item };
}
}
```#### TypeDormModule.forRootNonInjection(options)
```ts
import { Module } from '@nestjs/common';
import { TypeDormModule } from '@nest-dynamodb/typedorm';
import { AppController } from './app.controller';
@Module({
imports: [
TypeDormModule.forRootNonInjection({
table,
entities: [],
documentClient: new DocumentClientV3(new DynamoDBClient({})),
}),
],
controllers: [AppController],
})
export class AppModule {}
``````ts
import { Controller, Get, } from '@nestjs/common';
import { TypeDormConnection } from '@nest-dynamodb/typedorm';
@Controller()
export class AppController {
constructor(
// do not need InjectTypeDorm here
private readonly connection: TypeDormConnection,
) {}
@Get()
async getHello() {
const item = await this.connection.entityManager.findOne(...);
return { item };
}
}
```## License
MIT