{"id":18225,"library":"cmp-aws-database","title":"Craft My Plate AWS Database","description":"Defines global tables for the Craft My Plate application ecosystem, providing a shared database schema and utilities for AWS-based deployments. Current stable version is 1.7.1, released as needed alongside the main application. It is tightly coupled with the Craft My Plate monorepo and is not designed for independent use. Export models include DynamoDB table definitions and helper functions for common database operations.","status":"active","version":"1.7.1","language":"javascript","source_language":"en","source_url":"https://github.com/Surajpatel24-craftmyplate/craft-my-plate-database","tags":["javascript","npm"],"install":[{"cmd":"npm install cmp-aws-database","lang":"bash","label":"npm"},{"cmd":"yarn add cmp-aws-database","lang":"bash","label":"yarn"},{"cmd":"pnpm add cmp-aws-database","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for AWS DynamoDB client and table operations.","package":"aws-sdk","optional":false},{"reason":"Used for schema validation of table items.","package":"zod","optional":true}],"imports":[{"note":"Package is ESM-only; require() will fail. Use named import.","wrong":"const UserTable = require('cmp-aws-database').UserTable","symbol":"UserTable","correct":"import { UserTable } from 'cmp-aws-database'"},{"note":"RecipeTable is a named export, not default. Do not use default import.","wrong":"import RecipeTable from 'cmp-aws-database'","symbol":"RecipeTable","correct":"import { RecipeTable } from 'cmp-aws-database'"},{"note":"Function to obtain a configured DynamoDB client.","wrong":null,"symbol":"getDatabaseClient","correct":"import { getDatabaseClient } from 'cmp-aws-database'"}],"quickstart":{"code":"import { UserTable, RecipeTable, getDatabaseClient } from 'cmp-aws-database';\n\nconst client = getDatabaseClient({\n  region: 'us-east-1',\n  accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',\n  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? ''\n});\n\nasync function createUser(userId: string, name: string) {\n  const params = {\n    TableName: UserTable.name,\n    Item: { userId, name, createdAt: new Date().toISOString() }\n  };\n  await client.put(params).promise();\n  console.log('User created');\n}\n\ncreateUser('123', 'Alice').catch(console.error);","lang":"typescript","description":"Initializes the database client and creates a user item in the UserTable."},"warnings":[{"fix":"Upgrade Node.js to version 16 or higher.","message":"Version 2.0 removes support for Node.js 14 and below.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Import the table constant (e.g., UserTable.name) to avoid mismatches.","message":"Table names are defined as constants (e.g., 'cmp-users'). Do not hardcode table names; use the exported constants.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace getDB() with getDatabaseClient().","message":"The function 'getDB' is deprecated in favor of 'getDatabaseClient'.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Pass region explicitly to getDatabaseClient().","message":"All tables are defined in the us-east-1 region by default. If your stack uses a different region, you must override it in the client configuration.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update validation logic to use Zod schemas exposed by the package.","message":"In version 1.6.0, the schema validation library changed from Joi to Zod. Existing implicit validation will break.","severity":"breaking","affected_versions":">=1.6.0 <1.6.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install cmp-aws-database' and ensure tsconfig.json includes 'moduleResolution': 'node'.","cause":"The package is not installed or TypeScript cannot locate its types.","error":"Cannot find module 'cmp-aws-database' or its corresponding type declarations."},{"fix":"Use 'import { UserTable } from 'cmp-aws-database''.","cause":"Importing incorrectly (e.g., using default import instead of named import).","error":"TypeError: UserTable.name is undefined"},{"fix":"Ensure all required fields per the Zod schema are provided in the item object.","cause":"Missing required field when putting item into a table with Zod validation.","error":"ValidationError: \"name\" is required"},{"fix":"Provide region in the config object to getDatabaseClient().","cause":"getDatabaseClient() called without region option.","error":"Region is missing"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}