nestjs-dynamoose is a module designed to seamlessly integrate the Dynamoose ODM (Object Document Mapper) for DynamoDB into NestJS applications. It provides NestJS-specific modules and decorators that leverage NestJS's robust dependency injection system, allowing developers to define DynamoDB schemas and models in a structured, modular way. The current stable version is 0.6.0, with releases occurring frequently to maintain compatibility with new versions of NestJS and Dynamoose. Key differentiators include its adherence to NestJS architectural patterns (e.g., `forRoot`, `forFeature`), simplifying the setup and management of DynamoDB connections and models compared to integrating Dynamoose directly without the NestJS wrapper, and enabling easy configuration of AWS credentials and local DynamoDB instances.
npm install nestjs-dynamooseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure Dynamoose at the root of a NestJS application, define a Dynamoose schema, register it with a feature module, and inject the Dynamoose model into a service for data operations.
Ensure your NestJS monorepo dependencies (`@nestjs/common`, `@nestjs/core`) match the peer dependency range specified for the installed `nestjs-dynamoose` version.
Refactor your `DynamooseModule.forFeature()` configuration. Instead of `schema: { tableName: 'my-table', ... }`, use `options: { tableName: 'my-table' }` as a sibling to `schema`.Update all occurrences where you previously referred to 'document' in your code (e.g., interface names, variable names) to 'item'.
Upgrade your `dynamoose` package to a version compatible with your `nestjs-dynamoose` installation, typically `^3.2.0` or `^4.0.0` depending on the `nestjs-dynamoose` version.
If defining `forRootAsync` with `useFactory`, ensure your factory function signature includes an ignored first parameter, e.g., `useFactory: async (_, configService: ConfigService) => ({ /* ... */ })`.Ensure `DynamooseModule.forFeature()` is imported in the relevant feature module and that `InjectModel('YourModelName')` is used correctly in the service constructor, matching the name provided in `forFeature`.Add `DynamooseModule.forRoot()` (or `forRootAsync()`) to the `imports` array of your main `AppModule` to initialize the Dynamoose connection.
Check your `package.json` and `package-lock.json` for multiple versions of `dynamoose` or its types. Try `npm dedupe` or manually adjust versions to a single, compatible one.
Move `tableName` from the schema definition to the `options` property within the object passed to `DynamooseModule.forFeature()`, ensuring it's a string.