{"id":27359840,"url":"https://github.com/neuledge/ddb-table","last_synced_at":"2025-04-13T00:36:42.127Z","repository":{"id":37021618,"uuid":"258773083","full_name":"neuledge/ddb-table","owner":"neuledge","description":"🔒 Strongly typed library for querying and modeling DynamoDB documents in TypeScript.","archived":false,"fork":false,"pushed_at":"2024-06-20T11:22:02.000Z","size":2235,"stargazers_count":129,"open_issues_count":3,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T00:36:36.201Z","etag":null,"topics":["dynamodb","library","nodejs","query","strongly-typed","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neuledge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"neuledge"}},"created_at":"2020-04-25T12:43:13.000Z","updated_at":"2025-03-25T13:27:33.000Z","dependencies_parsed_at":"2024-01-11T18:59:55.402Z","dependency_job_id":null,"html_url":"https://github.com/neuledge/ddb-table","commit_stats":{"total_commits":238,"total_committers":4,"mean_commits":59.5,"dds":"0.39915966386554624","last_synced_commit":"31b058e90eb8c2e34a46813319b4889134b76ce4"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuledge%2Fddb-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuledge%2Fddb-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuledge%2Fddb-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuledge%2Fddb-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neuledge","download_url":"https://codeload.github.com/neuledge/ddb-table/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650415,"owners_count":21139671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamodb","library","nodejs","query","strongly-typed","typescript"],"created_at":"2025-04-13T00:36:41.551Z","updated_at":"2025-04-13T00:36:42.116Z","avatar_url":"https://github.com/neuledge.png","language":"TypeScript","funding_links":["https://github.com/sponsors/neuledge"],"categories":["Cloud Data Warehousing"],"sub_categories":["IDE"],"readme":"\u003ch1 align=\"center\" style=\"text-align:center\"\u003e🔒 DDB-Table\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eStrongly typed library for querying and modeling DynamoDB documents in TypeScript.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.org/package/ddb-table\"\u003e\n    \u003cimg src=\"http://img.shields.io/npm/v/ddb-table.svg\" alt=\"View On NPM\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/neuledge/ddb-table/actions/workflows/build.yml\"\u003e\n    \u003cimg src=\"https://github.com/neuledge/ddb-table/actions/workflows/build.yml/badge.svg\"\n      alt=\"Build Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://depfu.com/github/neuledge/ddb-table?project_id=13055\"\u003e\n    \u003cimg src=\"https://badges.depfu.com/badges/c06bc1e007e8b7f804d8563a56bb2ced/overview.svg\"\n      alt=\"Dependency Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/neuledge/ddb-table\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/neuledge/ddb-table/branch/master/graph/badge.svg?token=JQG7E9QJ3B\"\n      alt=\"Coverage Status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/ddb-table.svg\" alt=\"License\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n**DDB-Table** was built to provide strongly-typed data structures over DynamoDB tables. Using **AWS\nDocumentClient** \u0026 **TypeScript** you can easily fetch and store any JSON document and validate it’s\nstructure statically. Query secondary indexes and run complicated update expressions without any\nerror on runtime.\n\n```ts\nawait table\n  .update('demo@example.com')\n  .set('FullName', 'John Doe')\n  // 🚨 TypeScript Error: 'fullName' is not assignable to 'Email' | 'FullName'\n  .condition((cond) =\u003e cond.eq('fullName', 'Johnny Doe'))\n  .exec();\n```\n\n### Main Features\n\n- **Strongly Typed** - End-to-end TypeScript validation for your data.\n- **Easy Query Expressions** - Automatically escape name attributes and values.\n- **Smart Projections** - Make sure you only access the fields you project.\n- **Query \u0026 Scan Indexes** - Complete support for global or local indexes.\n- **Pure JavaScript** - Also works without TypeScript.\n\n### Sponsored by ❤️\n\nIf you like this project, please [consider sponsoring us](https://github.com/sponsors/neuledge) to help us continue to maintain and improve\nthis project.\n\n\u003cbr\u003e\n\n## Install\n\n```bash\nnpm i ddb-table\n```\n\n\u003cbr\u003e\n\n## Usage\n\n```ts\nimport Table from 'ddb-table';\nimport { DynamoDBClient } from '@aws-sdk/client-dynamodb';\nimport { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';\n\n\ninterface MessageSchema {\n  threadId: string;\n  timestamp: number;\n  senderId: string;\n  message: string;\n  status: 'sent' | 'received';\n  tags?: Set\u003cstring\u003e;\n  attachments: {\n    name: string;\n    URL: string;\n  }[];\n}\n\nconst client = new DynamoDBClient({\n  // settings...\n});\n\n// create the basic table definition\nconst messages = new Table\u003cMessageSchema, 'threadId', 'timestamp'\u003e({\n  tableName: 'Messages',\n  primaryKey: 'threadId',\n  sortKey: 'timestamp',\n  documentClient: DynamoDBDocument.from(client);\n});\n\nconst updateRes = await messages\n  .update('john@gmail.com', 1588191225322)\n  .set('message', 'Hello World!')\n  .add('tags', new Set(['unread', 'important']))\n  .set('attachments', (exp) =\u003e\n    exp.listAppend([{ name: 'Test', URL: 'demo.com' }]),\n  )\n  .return('ALL_NEW')\n  .exec();\n\nconsole.log(updateRes.Attributes);\n```\n\n#### Working with indexes as well:\n\n```ts\n// create a secondary index definition\ntype SenderTimestampIndex = Pick\u003c\n  MessageSchema,\n  'threadId' | 'timestamp' | 'senderId'\n\u003e;\n\nconst outboxIndex = messages.index\u003c\n  SenderTimestampIndex,\n  'senderId',\n  'timestamp'\n\u003e('senderId-timestamp-index', 'senderId', 'timestamp');\n\nconst it = outboxIndex\n  .query()\n  .keyCondition((cond) =\u003e cond.eq('senderId', 'john@gmail.com'))\n  .keyCondition((cond) =\u003e\n    cond.between('timestamp', Date.now() - 3600e3, Date.now()),\n  )\n  .project({ threadId: 1, message: 1 })\n  .reverseIndex()\n  .entries();\n\nfor await (const item of it) {\n  console.log(item);\n}\n```\n\n### Error Handling\n\n```ts\nimport { DynamoDBExceptionName } from 'ddb-table';\n\ntry {\n  await table.put(...).exec();\n} catch (err) {\n  if ((err as DynamoDBServiceException)?.name === DynamoDBExceptionName.ConditionalCheckFailedException) {\n    // handle exception\n  }\n}\n```\n\n\u003cbr\u003e\n\n## License\n\n[MIT](LICENSE) license \u0026copy; 2022 [Neuledge](https://neuledge.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuledge%2Fddb-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuledge%2Fddb-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuledge%2Fddb-table/lists"}