{"_id":"dynamoose-decorator","_rev":"69-dbcedeeee088a2523e32f8b121e5c648","name":"dynamoose-decorator","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.2":{"name":"dynamoose-decorator","version":"1.0.2","author":{"name":"jinseok0","email":"jinseok.d@gmail.com"},"license":"MIT","_id":"dynamoose-decorator@1.0.2","maintainers":[{"name":"p1ayground","email":"jinseok.d@gmail.com"}],"homepage":"https://github.com/p1ayground/dynamoose-decorator#readme","bugs":{"url":"https://github.com/p1ayground/dynamoose-decorator/issues"},"dist":{"shasum":"447e4e0810a2c707edb813a9da8982132120b8d2","tarball":"https://registry.npmjs.org/dynamoose-decorator/-/dynamoose-decorator-1.0.2.tgz","fileCount":17,"integrity":"sha512-/PmWGJ+G1/uSmxaw6KYcIN+rALfeNB06IilP3LCvSbEy8Fwk7AeWN1nl0RASMiKvYG0D4t5e/p8zVNtvDMx7nA==","signatures":[{"sig":"MEUCIHFPvAM8eJ3Gp4is3o5PkcyXecadEhaaXmSWaFk3UQbnAiEAzHZxyfOZji+/wrZB2BmMwBh7SCGyDlp6FQcBDceaKmk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":136626},"main":"./dist/src/index.js","_from":"file:dynamoose-decorator-1.0.2.tgz","types":"./dist/src/index.d.ts","scripts":{"test":"jest","build":"esbuild ./src/index.ts --external:dynamoose --bundle --minify --platform=node --outfile=./dist/src/index.js --sourcemap && tsc --emitDeclarationOnly --outDir dist","lint:ts":"tsc --noEmit","lint:prettier":"prettier . --check"},"_npmUser":{"name":"p1ayground","email":"jinseok.d@gmail.com"},"_resolved":"/private/var/folders/zq/70jh05p136ld02vln82_yr8h0000gn/T/9be96983aac1044343c96c3ebb3764ec/dynamoose-decorator-1.0.2.tgz","_integrity":"sha512-/PmWGJ+G1/uSmxaw6KYcIN+rALfeNB06IilP3LCvSbEy8Fwk7AeWN1nl0RASMiKvYG0D4t5e/p8zVNtvDMx7nA==","repository":{"url":"git+https://github.com/p1ayground/dynamoose-decorator.git","type":"git"},"_npmVersion":"10.2.3","description":"generate a dynamoose schema with the decorator","directories":{},"_nodeVersion":"18.19.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^8.0.3","eslint":"^8.56.0","esbuild":"^0.19.11","ts-jest":"^29.1.2","prettier":"^3.1.1","dynamoose":"^3.2.1","typescript":"^5.3.3","@types/jest":"^29.5.11","@types/node":"^18.19.6","reflect-metadata":"^0.2.1","eslint-plugin-import":"^2.29.1","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^6.16.0","eslint-config-import-typescript":"^1.0.0","@typescript-eslint/eslint-plugin":"^6.16.0","eslint-import-resolver-typescript":"^3.6.1"},"peerDependencies":{"dynamoose":"^3.2.1"},"_npmOperationalInternal":{"tmp":"tmp/dynamoose-decorator_1.0.2_1706275568836_0.6567663446975869","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"dynamoose-decorator","version":"1.0.3","author":{"name":"jinseok0","email":"jinseok.d@gmail.com"},"license":"MIT","_id":"dynamoose-decorator@1.0.3","maintainers":[{"name":"p1ayground","email":"jinseok.d@gmail.com"}],"homepage":"https://github.com/p1ayground/dynamoose-decorator#readme","bugs":{"url":"https://github.com/p1ayground/dynamoose-decorator/issues"},"dist":{"shasum":"ab443dab5fb3846f886c7e7f4149dbe8863ebda5","tarball":"https://registry.npmjs.org/dynamoose-decorator/-/dynamoose-decorator-1.0.3.tgz","fileCount":17,"integrity":"sha512-gsfopSlKKNSce5VLWAEBT6+VqE/0adPnZO6D7eM25dcCXXNGNeSaEa+j9c0MB2pNZm1uO4rgLuKoCh5IGEzfIA==","signatures":[{"sig":"MEYCIQDKKK8N7I7OZeb8DpuZFW17MgBfSLx1/dl7QaYzbITD+QIhAPhBnXYSYXxltt1O9H6NtMtVLeuZlO+JkY7hUAf1qaOq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137508},"main":"./dist/src/index.js","_from":"file:dynamoose-decorator-1.0.3.tgz","types":"./dist/src/index.d.ts","scripts":{"test":"jest","build":"esbuild ./src/index.ts --external:dynamoose --bundle --minify --platform=node --outfile=./dist/src/index.js --sourcemap && tsc --emitDeclarationOnly --outDir dist","lint:ts":"tsc --noEmit","lint:prettier":"prettier . --check"},"_npmUser":{"name":"p1ayground","email":"jinseok.d@gmail.com"},"_resolved":"/private/var/folders/zq/70jh05p136ld02vln82_yr8h0000gn/T/264bb573a129379108a70b6b7fd42536/dynamoose-decorator-1.0.3.tgz","_integrity":"sha512-gsfopSlKKNSce5VLWAEBT6+VqE/0adPnZO6D7eM25dcCXXNGNeSaEa+j9c0MB2pNZm1uO4rgLuKoCh5IGEzfIA==","repository":{"url":"git+https://github.com/p1ayground/dynamoose-decorator.git","type":"git"},"_npmVersion":"10.2.3","description":"generate a dynamoose schema with the decorator","directories":{},"_nodeVersion":"18.19.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^8.0.3","eslint":"^8.56.0","esbuild":"^0.19.11","ts-jest":"^29.1.2","prettier":"^3.1.1","dynamoose":"^3.2.1","typescript":"^5.3.3","@types/jest":"^29.5.11","@types/node":"^18.19.6","reflect-metadata":"^0.2.1","eslint-plugin-import":"^2.29.1","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^6.16.0","eslint-config-import-typescript":"^1.0.0","@typescript-eslint/eslint-plugin":"^6.16.0","eslint-import-resolver-typescript":"^3.6.1"},"peerDependencies":{"dynamoose":"^3.2.1"},"_npmOperationalInternal":{"tmp":"tmp/dynamoose-decorator_1.0.3_1709311846122_0.2216152824474351","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"dynamoose-decorator","version":"1.0.4","author":{"name":"jinseok0","email":"jinseok.d@gmail.com"},"license":"MIT","_id":"dynamoose-decorator@1.0.4","maintainers":[{"name":"changmyeong","email":"changmyeong.baek@gmail.com"},{"name":"p1ayground","email":"jinseok.d@gmail.com"}],"homepage":"https://github.com/p1ayground/dynamoose-decorator#readme","bugs":{"url":"https://github.com/p1ayground/dynamoose-decorator/issues"},"dist":{"shasum":"8eee82e02a5ca5b536b50975f31c019c22396dc5","tarball":"https://registry.npmjs.org/dynamoose-decorator/-/dynamoose-decorator-1.0.4.tgz","fileCount":17,"integrity":"sha512-g5DrkXIchPyOy6U3FWpqwPNJZOUBypHtBKw69cVz5wDJv7Alefu4x/+IWpN/g5L3I3Nc9HcXLCJZYg3gZlp8vA==","signatures":[{"sig":"MEUCIQClnjVm7WdXmvaDLBxz6Y02jTOlpTW+u+ZIPo6lKVdqjgIgMl833RD6km+UCET3OIgZW7jClP0iqNWdBrb1aYDYx/I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":140843},"main":"./dist/src/index.js","types":"./dist/src/index.d.ts","gitHead":"cb4b8f32beae36521cccecd7884c4ed2ccf0d1cd","scripts":{"test":"jest","build":"esbuild ./src/index.ts --external:dynamoose --bundle --minify --platform=node --outfile=./dist/src/index.js --sourcemap && tsc --emitDeclarationOnly --outDir dist","lint:ts":"tsc --noEmit","prepare":"husky install","lint:prettier":"prettier . --check"},"_npmUser":{"name":"changmyeong","email":"changmyeong.baek@gmail.com"},"repository":{"url":"git+https://github.com/p1ayground/dynamoose-decorator.git","type":"git"},"_npmVersion":"10.9.2","description":"generate a dynamoose schema with the decorator","directories":{},"_nodeVersion":"23.11.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^8.0.3","eslint":"^8.56.0","esbuild":"^0.19.11","ts-jest":"^29.1.2","prettier":"^3.1.1","dynamoose":"^3.2.1","typescript":"^5.3.3","@types/jest":"^29.5.11","@types/node":"^18.19.6","reflect-metadata":"^0.2.1","eslint-plugin-import":"^2.29.1","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^6.16.0","eslint-config-import-typescript":"^1.0.0","@typescript-eslint/eslint-plugin":"^6.16.0","eslint-import-resolver-typescript":"^3.6.1"},"peerDependencies":{"dynamoose":"^3.2.1"},"_npmOperationalInternal":{"tmp":"tmp/dynamoose-decorator_1.0.4_1755656527410_0.4120031090483236","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"dynamoose-decorator","version":"1.0.5","description":"generate a dynamoose schema with the decorator","main":"./dist/src/index.js","scripts":{"build":"esbuild ./src/index.ts --external:dynamoose --external:reflect-metadata --bundle --minify --platform=node --outfile=./dist/src/index.js --sourcemap && tsc --emitDeclarationOnly --outDir dist","test":"jest","lint:ts":"tsc --noEmit","lint:prettier":"prettier . --check","prepare":"husky install"},"author":{"name":"jinseok0","email":"jinseok.d@gmail.com"},"license":"MIT","devDependencies":{"@types/jest":"^29.5.11","@types/node":"^18.19.6","@typescript-eslint/eslint-plugin":"^6.16.0","@typescript-eslint/parser":"^6.16.0","dynamoose":"^3.2.1","esbuild":"^0.19.11","eslint":"^8.56.0","eslint-config-import-typescript":"^1.0.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.6.1","eslint-plugin-import":"^2.29.1","husky":"^8.0.3","jest":"^29.7.0","prettier":"^3.1.1","reflect-metadata":"^0.2.1","ts-jest":"^29.1.2","typescript":"^5.3.3"},"peerDependencies":{"dynamoose":"^3.2.1","reflect-metadata":"^0.2.1"},"repository":{"type":"git","url":"git+https://github.com/p1ayground/dynamoose-decorator.git"},"_id":"dynamoose-decorator@1.0.5","gitHead":"aeaef70bb6622046f6be969cd85be7f787254144","types":"./dist/src/index.d.ts","bugs":{"url":"https://github.com/p1ayground/dynamoose-decorator/issues"},"homepage":"https://github.com/p1ayground/dynamoose-decorator#readme","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-WyLkRvhIHY0dAFolO1auTWu1gPOnk56zmpr1eR8oGHb5MIwGzG6jkbDUZUnRi0gR7qiX7IHO5i05R4UDm59Tow==","shasum":"6909ed2da5410bf7d0ebe5a0af22a83bc5673800","tarball":"https://registry.npmjs.org/dynamoose-decorator/-/dynamoose-decorator-1.0.5.tgz","fileCount":17,"unpackedSize":38690,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB3VfUKF94VcfwtvFHz8HinOQz+Ld5QIE0nf8YGhDhiyAiBONSjs6xN5qyy90RG3o+cuoaxXWQga49CzYhy9c6yvlg=="}]},"_npmUser":{"name":"changmyeong","email":"changmyeong.baek@gmail.com"},"directories":{},"maintainers":[{"name":"changmyeong","email":"changmyeong.baek@gmail.com"},{"name":"p1ayground","email":"jinseok.d@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dynamoose-decorator_1.0.5_1759762648185_0.6494173843171123"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-30T13:00:21.170Z","modified":"2025-10-06T14:57:28.545Z","3.1.0":"2023-04-12T11:41:53.681Z","0.0.0-beta.1":"2023-05-30T13:00:21.379Z","0.0.0-beta.2":"2023-06-04T11:19:40.545Z","0.0.0-beta.3":"2023-06-04T11:23:50.236Z","0.0.0-beta.4":"2023-06-04T11:33:58.501Z","0.0.0-beta.5":"2023-06-04T11:35:11.483Z","0.0.0-beta.6":"2023-06-04T11:55:28.701Z","3.2.0":"2023-06-18T18:36:58.444Z","3.2.1":"2023-09-11T07:41:09.597Z","3.2.1-1":"2023-09-11T07:45:26.894Z","3.2.1-2":"2023-09-11T08:00:26.715Z","3.2.1-3":"2023-09-11T08:39:48.910Z","3.2.1-4":"2023-09-11T09:02:44.535Z","3.1.0-beta1":"2023-09-11T09:34:15.317Z","3.1.0-beta2":"2023-09-11T09:40:57.170Z","3.1.0-beta3":"2023-09-11T09:41:07.461Z","3.1.0-beta4":"2023-09-11T09:47:04.741Z","3.1.1":"2023-12-30T18:44:27.011Z","3.1.2":"2023-12-30T20:40:34.531Z","3.2.10":"2024-01-12T12:36:18.623Z","3.2.11":"2024-01-20T18:16:59.530Z","3.3.1":"2024-01-20T18:20:09.518Z","4.0.1":"2024-01-20T18:21:47.410Z","3.2.2":"2024-01-20T20:17:53.786Z","3.2.12":"2024-01-20T20:20:06.418Z","3.3.2":"2024-01-20T20:21:54.234Z","4.0.2":"2024-01-20T20:23:00.449Z","1.0.1":"2024-01-26T13:17:07.326Z","1.0.1-beta":"2024-01-26T13:24:12.688Z","1.0.2":"2024-01-26T13:26:08.978Z","1.0.3":"2024-03-01T16:50:46.345Z","1.0.4":"2025-08-20T02:22:07.601Z","1.0.5":"2025-10-06T14:57:28.368Z"},"bugs":{"url":"https://github.com/p1ayground/dynamoose-decorator/issues"},"author":{"name":"jinseok0","email":"jinseok.d@gmail.com"},"license":"MIT","homepage":"https://github.com/p1ayground/dynamoose-decorator#readme","repository":{"type":"git","url":"git+https://github.com/p1ayground/dynamoose-decorator.git"},"description":"generate a dynamoose schema with the decorator","maintainers":[{"name":"changmyeong","email":"changmyeong.baek@gmail.com"},{"name":"p1ayground","email":"jinseok.d@gmail.com"}],"readme":"\n<h1 align=\"center\">dynamoose-decorator</h1>\n\nThis library provides decorators to enhance the usability of dynamoose, a Node.js object data modeling library for AWS DynamoDB.\n\n```typescript\nimport { Item } from 'dynamoose/dist/Item';\nimport {\n  HashKey,\n  Attribute,\n  Required,\n  Index,\n  CreatedAt,\n  UpdatedAt,\n  Model,\n  Storage,\n  getModel,\n} from 'dynamoose-decorator';\n\n@Model({ throughput: 'ON_DEMAND', waitForActive: false })\n@Schema({ saveUnknown: true })\nclass UserSchema extends Item {\n  @HashKey()\n  id: string;\n\n  @Index({ name: 'emailIndex' })\n  @Required()\n  email: string;\n\n  @Index({ name: 'nameIndex' })\n  @Required()\n  name: string;\n\n  @Index({ name: 'companyAndScoreIndex', rangeKey: 'score' })\n  company: string;\n\n  @Attribute()\n  score: number;\n\n  @Storage('milliseconds')\n  @CreatedAt()\n  createdAt: Date;\n\n  @Storage('milliseconds')\n  @UpdatedAt()\n  updatedAt: Date;\n}\n\nexport const UserModel = getModel(UserSchema)\n\nconst user = new UserModel();\nuser.id = 'bf02318d-4029-4474-a7a0-e957eb176d75';\nuser.email = 'test@dynamoose.com';\nuser.name = 'DYNAMOOSE';\nuser.company = 'Amazon';\nuser.score = 3;\n\nawait user.save();\n```\n\n## Getting started\n\ninstall using `npm`\n\n```bash\nnpm install dynamoose-decorator dynamoose reflect-metadata\n```\n\ninstall using `yarn`\n\n```bash\nyarn add dynamoose-decorator dynamoose reflect-metadata\n```\n\ninstall using `pnpm`\n\n```bash\npnpm add dynamoose-decorator dynamoose reflect-metadata\n```\n\n⚠️ **Note:** `reflect-metadata` is required as a peer dependency. Make sure it's installed in your project.\n\nModify your `tsconfig.json` to enable decorator support:\n\n```json\n{\n  \"compilerOptions\": {\n    \"experimentalDecorators\": true,\n    \"emitDecoratorMetadata\": true,\n  }\n}\n```\n\n## Attribute\n### `@Attribute`\nDefine attribute for a Dynamoose model. This decorator is optional when using other decorators like `@HashKey`, `@Required`, `@Index`, etc.\n```typescript\nimport { Attribute } from 'dynamoose-decorator';\n\n@Attribute()\nname: string;\n```\n\n⚠️ **Note:** You have to set true `saveUnknown` in `@Schema` when use object field.\n```\ninterface RoleInterface {\n  name: string;\n  grade: string;\n}\n\n@Schema({ saveUnknown: true })\nclass UserModel {\n  @Attribute()\n  role: RoleInterface;\n}\n```\n\n### `@HashKey`\nYou can set this decorator to overwrite what the Hash Key for the Model will be.\nHash Key is commonly called a Partition Key in the AWS Documentation.\n\n⚠️ **Note:** Hash keys can only be specified for attributes of types Number, String, and Binary.\n```typescript\nimport { HashKey } from 'dynamoose-decorator';\n\n@HashKey()\nid: string;\n```\n\n### `@RangeKey`\nYou can set this decorator to overwrite what the Range Key for the Model will be. By default the `@RangeKey` won't exist.\nRange Key is commonly called a Sort Key in the AWS Documentation.\n\n```typescript\nimport { RangeKey } from 'dynamoose-decorator';\n\n@RangeKey()\nscore: number;\n```\n\n### `@Required`\nYou can set this decorator to be required when saving items to DynamoDB. By default this setting is `false`.\n\n```typescript\nimport { Required } from 'dynamoose-decorator';\n\n@Required()\nemail: string;\n```\n\n\n### `@Default`\nIt is decorate [Dynamoose default](https://dynamoosejs.com/guide/Schema#default-value--function--async-function). You can set this decorator for an attribute that will be applied upon save if the given attribute value is null or undefined. The value for the default property can either be a value or a function that will be executed when needed that should return the default value. By default there is no default value for attributes.\n\nDefault values will only be applied if the parent object exists. This means for values where you apply a default value to a nested attribute, it will only be applied if the parent object exists. If you do not want this behavior, consider setting a default value for the parent object to an empty object ({}) or an empty array ([]).\n```typescript\nimport { Default } from 'dynamoose-decorator';\n\n@Default(5)\nage: number;\n\n@Default(async () => {\n  const response = await axios(\"https://myurl.com/config.json\").data;\n  return response.defaults.age;\n})\nstate: string;\n```\n\n### `@ForceDefault`\nYou can set this property to always use the default value, even if a value is already set. This can be used for data that will be used as sort or secondary indexes. The default for this property is false.\n```typescript\nimport { ForceDefault, Default } from 'dynamoose-decorator';\n\n@ForceDefault()\n@Default(5)\nage: number;\n```\n\n\n## `@Enum`\nYou can set an attribute to have an enum array, which means it must match one of the values specified in the enum array. By default this setting is undefined and not set to anything.\n\nThis property is not a replacement for required. If the value is undefined or null, the enum will not be checked. If you want to require the property and also have an enum you must use both enum & required.\n```typescript\nimport { Enum } from 'dynamoose-decorator';\n\n@Enum(['amazon', 'apple'])\ncompany: string;\n```\n\n\n### `@Storage`\nSet storage settings for an attribute of type Date.  \nBy default this setting is `milliseconds`.\n```typescript\nimport { Storage } from 'dynamoose-decorator';\n\n// Stored as a timestamp in DynamoDB.\n// It is saved as number type.\n@Storage('milliseconds')\ntimestamp: Date;\n\n// Stored as a iso date in DynamoDB.\n// It is saved as string type.\n@Storage('iso')\nisodate: Date;\n```\n\n### `@CreatedAt`, `@UpdatedAt`\nSpecial column that is automatically set to the entity's insertion or update time. You don't need to write a value into this column.\n\n⚠️ **Note:** These features are not features of DynamoDB. it will set by the Dynamoose.\n\n```typescript\nimport { CreatedAt, UpdatedAt, Storage } from 'dynamoose-decorator';\n\n@CreatedAt()\ncreatedAt: Date;\n\n@UpdatedAt()\nupdatedAt: Date;\n\n@Storage('iso')\n@CreatedAt()\ncreatedIsoDate: Date;\n\n@Storage('iso')\n@UpdatedAt()\nupdatedIsoDate: Date;\n```\n\n## Schema\nIt is decorate Dynamoose schema.  \nPlease refer to the [Dynamoose documentation](https://dynamoosejs.com/guide/Schema#new-dynamooseschemaschema-options) for options.\n\n```typescript\nimport { Schema } from 'dynamoose-decorator';\nimport { Item } from 'dynamoose/dist/Item';\n\n@Schema({ saveUnknown: true })\nclass UserSchema extends Item {\n  // attributes ..\n}\n```\n\n## Model\nYou can set this decorator to [table options](https://dynamoosejs.com/guide/Table#new-dynamoosetablename-models-options).  \nHowever, we automatically set the name of the table to the class name. If you want to change the table name, use the `tableName` option.\n\nYou must use the `Schema` class by converting it to a Dynamoose Model object through the `getModel` function.\n\n```typescript\nimport { Schema, getModel, HashKey, RangeKey, Attribute } from 'dynamoose-decorator';\nimport { Item } from 'dynamoose/dist/Item';\n\n// The table name for this entity is `User`.\n@Model({ throughput: 'ON_DEMAND' })\n@Schema()\nclass UserSchema {\n  @HashKey()\n  id: string;\n\n  @RangeKey()\n  score: number;\n}\n\n// Set the table name you want!\n@Model({ tableName: 'prod-Order', throughput: { read: 1, write: 1 } })\n@Schema()\nclass OrderSchema {\n\n}\n\n// Convert to Dynamoose Model\nconst UserModel = getModel(UserSchema);\nconst OrderModel = getModel(OrderSchema);\n\n// Same use as Dynamoose!\nawait UserModel.create({\n  id: 'hello',\n  score: 100,\n});\n\nconst user = new UserModel();\nuser.id = 'world';\nuser.score = 200;\nawait user.save();\n```\n\n\n## Maintainer\n- [jinseok0](https://github.com/jinseok0)\n- [changmyeong](https://github.com/changmyeong)","readmeFilename":"README.md"}