{"id":16344,"library":"dynamo-seeder","title":"DynamoDB Seeder","description":"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.","status":"abandoned","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/samverschueren/dynamo-seeder","tags":["javascript","dynamodb","seeder"],"install":[{"cmd":"npm install dynamo-seeder","lang":"bash","label":"npm"},{"cmd":"yarn add dynamo-seeder","lang":"bash","label":"yarn"},{"cmd":"pnpm add dynamo-seeder","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the underlying connection and interaction layer for DynamoDB operations. It abstracts DynamoDB's API with a MongoDB-like syntax.","package":"dynongo"}],"imports":[{"note":"This package is primarily CommonJS-oriented, as indicated by its age and the documentation's `require` usage. Direct ESM import (`import seeder from 'dynamo-seeder'`) may not work without a CommonJS wrapper or bundler configuration.","symbol":"seeder","correct":"const seeder = require('dynamo-seeder');"},{"note":"The `connect` method initializes the DynamoDB client, often requiring configuration like table prefixes. Credentials should ideally be managed via environment variables or IAM roles, though direct credential passing is possible with `dynongo`'s underlying connection.","symbol":"seeder.connect","correct":"const seeder = require('dynamo-seeder');\nseeder.connect({ prefix: 'my-app' });"},{"note":"The `seed` method initiates the data population process. The `dropTables` option is critical, as `true` will delete and recreate tables, leading to data loss if not used carefully.","symbol":"seeder.seed","correct":"const seeder = require('dynamo-seeder');\nseeder.seed(data, { dropTables: true });"}],"quickstart":{"code":"const seeder = require('dynamo-seeder');\nconst path = require('path');\nconst fs = require('fs');\n\n// Mock schema data for UserTable.json\nconst userSchema = {\n    \"TableName\": \"User\",\n    \"AttributeDefinitions\": [\n        { \"AttributeName\": \"email\", \"AttributeType\": \"S\" }\n    ],\n    \"KeySchema\": [\n        { \"AttributeName\": \"email\", \"KeyType\": \"HASH\" }\n    ],\n    \"ProvisionedThroughput\": {\n        \"ReadCapacityUnits\": 1,\n        \"WriteCapacityUnits\": 1\n    }\n};\n\n// Create a dummy schema file for the seeder to find\nconst schemaPath = path.join(__dirname, 'UserSchema.json');\nfs.writeFileSync(schemaPath, JSON.stringify(userSchema, null, 2));\n\n// Mock data for seeding\nconst seedData = {\n    \"users\": {\n        \"_schema\": \"./UserSchema.json\",\n        \"foo\": {\n            \"firstName\": \"Foo\",\n            \"name\": \"Bar\",\n            \"fullName\": \"=this.firstName + ' ' + this.name\",\n            \"email\": \"foo@bar.com\",\n            \"birthday\": \"=new Date(1988, 8, 16).toISOString()\"\n        },\n        \"bar\": {\n            \"firstName\": \"Baz\",\n            \"name\": \"Qux\",\n            \"email\": \"baz@qux.com\"\n        }\n    }\n};\n\nasync function runSeeder() {\n    try {\n        // Connect to DynamoDB (defaults to local DynamoDB if not configured explicitly)\n        // For AWS, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION are set as env vars\n        seeder.connect({\n            prefix: 'mytestapp.', // Prefix for table names\n            local: process.env.DYNAMODB_LOCAL === 'true', // Connect to DynamoDB Local\n            // For local, you might also need host/port:\n            // host: 'localhost',\n            // localPort: 8000\n        });\n\n        console.log('Seeding DynamoDB tables...');\n        await seeder.seed(seedData, { dropTables: true }); // dropTables: true will recreate tables\n        console.log('Database successfully seeded!');\n    } catch (err) {\n        console.error('Error seeding database:', err);\n    } finally {\n        // Clean up dummy schema file\n        fs.unlinkSync(schemaPath);\n        // In a real application, you might disconnect or simply exit\n        process.exit(0);\n    }\n}\n\n// Ensure DYNAMODB_LOCAL is set to 'true' to run against local DynamoDB for testing\n// Otherwise, ensure AWS credentials are configured for remote DynamoDB\nprocess.env.DYNAMODB_LOCAL = process.env.DYNAMODB_LOCAL ?? 'true'; \n\nrunSeeder();","lang":"javascript","description":"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."},"warnings":[{"fix":"Always pin to exact minor versions (e.g., `\"dynamo-seeder\": \"0.5.0\"`) and review release notes if available before upgrading.","message":"As a package in pre-1.0.0 status (v0.5.0), `dynamo-seeder` may introduce breaking changes between minor versions without adhering to semantic versioning guarantees. Developers should test thoroughly when updating.","severity":"breaking","affected_versions":">=0.x.x"},{"fix":"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.","message":"The `dropTables: true` option in `seeder.seed()` will permanently delete existing tables and their data before recreating them. Using this in production environments will lead to severe data loss.","severity":"breaking","affected_versions":">=0.x.x"},{"fix":"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`.","message":"The package uses `dynongo` internally, which relies on AWS SDK v2. Its age (last updated 5 years ago) means it may not be compatible with newer Node.js versions or the latest AWS SDK v3, potentially leading to dependency conflicts or unexpected behavior.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"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.","message":"Expressions within JSON data, like `\"=new Date().toISOString()\"` or `\"=this.firstName + this.name\"`, are evaluated using JavaScript's `eval`-like mechanism. If seed data originates from untrusted sources, this could lead to arbitrary code execution (a supply chain attack vector if malicious data is injected).","severity":"gotcha","affected_versions":">=0.x.x"},{"fix":"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.","message":"The `_schema` path in the JSON data is relative to where `seeder.seed()` is called. Incorrect relative paths will result in 'schema not found' errors, halting the seeding process.","severity":"gotcha","affected_versions":">=0.x.x"},{"fix":"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.","message":"This package appears to be abandoned or in deep maintenance, with no recent updates (last publish 5 years ago) and a low version number (0.5.0). It is unlikely to receive bug fixes, security patches, or new features.","severity":"deprecated","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"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.","cause":"The `_schema` path specified in your JSON data (e.g., `./path/to/Schema.json`) is incorrect or the file does not exist at the resolved location.","error":"Error: Schema could not be found for table: <TableName>"},{"fix":"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.","cause":"This error likely indicates a misconfiguration in how `dynongo` (the underlying library used by `dynamo-seeder`) connects to DynamoDB, or an issue with the AWS SDK setup.","error":"AWS.DynamoDB.createTable is not a function"},{"fix":"Change your import statement to `const seeder = require('dynamo-seeder');` to correctly load the CommonJS module.","cause":"You might be attempting to import `dynamo-seeder` using an ES module syntax (`import seeder from 'dynamo-seeder'`) in an environment where it's only exported as a CommonJS module.","error":"seeder.connect is not a function"}],"ecosystem":"npm"}