@@ -53,6 +53,47 @@ There are some proposals you can use:
5353
5454## Documentation
5555
56+ ### Item Duplication
57+
58+ ** Item duplication requires ` dynamodb:BatchWriteItem ` enabled.**
59+
60+ When you need to duplicate an object to many items at once, you can use `` @DuplicateTo `` annotation:
61+
62+ ````
63+ /**
64+ * @Dynamite\Item(objectType="USER")
65+ * @Dynamite\PartitionKeyFormat("USER#{id}")
66+ * @Dynamite\SortKeyFormat("USER")
67+ * @Dynamite\DuplicateTo(pk="UDATA#{email}", sk="UDATA", props={"id", "username"})
68+ * @Dynamite\DuplicateTo(pk="UDATA#{username}", sk="UDATA", props={"id", "email"})
69+ */
70+ class User {
71+ //...props
72+ }
73+
74+ $user = new User('123', '[email protected] ', 'mickey') 75+ ````
76+
77+ In this case, There will be 3 items sent to DynamoDB:
78+ - PK: ` USER#123 ` SK:` USER ` with ** all** attributes defined in item;
79+ - PK: ` UDATA#user@example ` SK: ` UDATA ` with ` id ` and ` username ` props;
80+ - PK: ` UDATA#mickey ` SK: ` UDATA ` with ` id ` and ` email ` props.
81+
82+
83+ You can add a ` transform ` param to annotation to fill Primary key pair with lowercased/uppercased params:
84+
85+
86+ ````
87+
88+ //In this case PK: UDATA#MICKEY
89+ @Dynamite\DuplicateTo(pk="UDATA#{username}", sk="UDATA", props={"id", "email"}, transform="UPPER")
90+
91+ //In this case PK: UDATA#mickey
92+ @Dynamite\DuplicateTo(pk="UDATA#{username}", sk="UDATA", props={"id", "email"}, transform="LOWER")
93+ ````
94+
95+ By default params are passed as-is. ` transform ` works only for params injected to key, key template remains untouched.
96+
5697
5798### Creating an Item
5899
0 commit comments