dynamo-seeder is a Node.js library designed to simplify the process of populating DynamoDB tables with initial data, often referred to as 'seeding.' It works by accepting JSON data, which can include references to external schema definitions for table creation and item data. The library supports basic data insertion and more advanced features like inline JavaScript expressions for dynamic data generation (e.g., dates, concatenated strings) and dependency injection for external libraries like `moment.js` within these expressions. Currently at version 0.5.0, it is not actively maintained, with its last known activity several years ago. It relies on `dynongo` for DynamoDB interactions, which itself appears to be in maintenance mode. This tool differentiates itself by allowing highly structured JSON data, including schema definitions and computed fields, directly within the seeding configuration, rather than solely relying on code-driven seeding.
npm install dynamo-seederVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `dynamo-seeder` to connect to DynamoDB (local or remote), define table schemas and data in JSON, and seed the database. It includes an example of dynamic data generation using JavaScript expressions and the `dropTables` option for fresh seeding.
Always pin to exact minor versions (e.g., `"dynamo-seeder": "0.5.0"`) and review release notes if available before upgrading.
Exercise extreme caution with `dropTables: true`. Ensure it is only enabled for development or testing environments where data loss is acceptable. For production, consider using a migration tool or a strategy that only inserts/updates data without dropping tables.
Test `dynamo-seeder` carefully with your specific Node.js version and other AWS SDK dependencies. Consider using an alternative, more actively maintained DynamoDB seeding solution if compatibility issues arise. For AWS SDK v3, consider tools like `@cloudcomponents/cdk-dynamodb-seeder` or `dyngoose`.
Ensure all seed data, especially any containing expressions, is thoroughly vetted and comes from trusted sources. Do not use this feature with user-provided or otherwise untrusted input. Consider sanitizing or validating expressions if they must be dynamic.
Always verify the `_schema` paths are correct relative to the script executing `seeder.seed()`. Use `path.join(__dirname, 'schema-folder', 'MySchema.json')` for robustness if constructing paths dynamically.
Consider migrating to more actively maintained DynamoDB seeding or migration tools like those integrated with AWS CDK (`@cloudcomponents/cdk-dynamodb-seeder`, `aws-cdk-dynamodb-seeder`) or general-purpose data loaders for DynamoDB.
Double-check the relative path to your schema file from the directory where you execute the seeding script. Ensure the file exists and is accessible.
Ensure your AWS credentials and region are correctly configured (e.g., via environment variables or a `~/.aws/credentials` file). If using `dynamodb-local`, verify the `local: true` option is passed to `seeder.connect()` and the local instance is running.
Change your import statement to `const seeder = require('dynamo-seeder');` to correctly load the CommonJS module.