You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-31Lines changed: 48 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,22 +78,9 @@ present on a property)
78
78
79
79
Generic information is never available due to some serialization limitations at the time of writing.
80
80
81
-
## A word on Collections (Array & Set)
82
-
83
-
###Array
84
-
Javascript Arrays with a a items of type String, Number or Binary will be mapped to a S(et) type, by default all other types are mapped to L(ist) type.
85
-
If an item of an Array has a complex type the type can be defined using the @TypedArray() Decorator.
86
-
87
-
###Set
88
-
ES6 Set types will be marshalled to dynamoDb set type if the type of the set is supported, if the type is not supported it will be
89
-
marshalled to an dynamoDB List.
90
-
91
-
When one of the following decorators is added, the value is marshalled to a List type.
Here is the rule how a table name is built `${kebabCase(modelName)}s` so for a model called Product the table will be named products, this is a default implementation.
98
85
99
86
There are two possibilities to change the name:
@@ -121,17 +108,51 @@ Complex Types (properties with these types need some decorators to work properly
121
108
- Map
122
109
- Array<complexType>
123
110
111
+
| TS Type | Dynamo Type |
112
+
| ------------- |:-------------:|
113
+
| String | S |
114
+
| Number | N |
115
+
| Boolean | BOOL |
116
+
| moment.Moment | S (ISO-8601 formatted) |
117
+
| null | NULL |
118
+
| Array | L, (S,N,B)S |
119
+
| ES6 Set | L, (S,N,B)S |
120
+
| Object | M |
121
+
|----|------|
122
+
| Binary | Not Supported |
123
+
| ES6 Map | Not Supported |
124
+
| Date | Not Supported |
125
+
126
+
## Custom Attribute Mapping
127
+
It is always possible to define a custom mapping strategy, just implement the [MapperForType](https://shiftcode.github.io/dynamo-easy/interfaces/_mapper_for_type_base_mapper_.mapperfortype.html) class.
128
+
129
+
## Collection Mapping (Array & Set)
130
+
131
+
### Array
132
+
Javascript Arrays with a items of type String, Number or Binary will be mapped to a S(et) type, by default all other types are mapped to L(ist) type.
133
+
If the items have a complex type it will be mapped to a L(ist).
134
+
135
+
### Set
136
+
An instance of ES6 Set type will be mapped to a S(et) type if the type of the items is supported (String, Number, Binary), otherwise it is mapped to a L(ist).
137
+
138
+
When one of the following decorators is present, the value is always mapped to a L(ist).
139
+
140
+
-@SortedSet(itemType?: ModelClazz) - only L(ist) type preserves order
141
+
-@TypedSet(itemType?: ModelClazz) - if the itemType is not one of String | Number | Binary
142
+
-@TypedArray()
143
+
124
144
## Date
125
-
Right now we only support (MomentJS)[http://momentjs.com/] Dates.
145
+
Right now we only support [MomentJS](http://momentjs.com/) Dates.
126
146
127
147
If you want to explicitly mark a property to be a Date use the @Date() decorator. If we find a moment value we automatically map it to a String (using ISO-8601 format).
128
148
When coming from db we do a regex test for ISO-8601 format and map it back to a moment object.
129
149
130
-
# Requests API
131
-
To start making requests create an instance of [DynamoStore](https://shiftcode.github.io/dynamo-easy/classes/_dynamo_dynamo_store_.dynamostore.html) and execute the desired operation using the provided api.
132
-
We support all the common dynamodb operations.
150
+
## Enum
151
+
Enum values are persisted as Numbers (index of enum).
133
152
134
-
The request api has support for the following operations:
153
+
# Request API
154
+
To start making requests create an instance of [DynamoStore](https://shiftcode.github.io/dynamo-easy/classes/_dynamo_dynamo_store_.dynamostore.html) and execute the desired operation using the provided api.
155
+
We support all the common dynamodb operations:
135
156
136
157
- Put
137
158
- Get
@@ -141,9 +162,6 @@ The request api has support for the following operations:
141
162
- Query
142
163
- MakeRequest (generic low level method for special scenarios)
143
164
144
-
For most of the api there is probably no explanation required, here are some topics we think
145
-
need some more info.
146
-
147
165
There is always the possibility to access the Params object directly to add values which are not covered with our api.
148
166
149
167
# Authentication
@@ -154,8 +172,8 @@ The default implementation is a no-op function.
154
172
## Session Validity Ensurer
155
173
Here is an example of an implementation using amazon cognito
@@ -226,18 +244,17 @@ which publishes our code automatically on github and npm, plus generates automat
226
244
We use 2 git hooks:
227
245
228
246
`precommit`
229
-
- to format the code with Prettier :nail_care: before sending it to the git repo.
247
+
- to format the code with Prettier :nail_care:
230
248
- to check if the commit message follows a [conventional commit message](https://github.com/conventional-changelog/conventional-changelog)
231
249
232
-
233
250
`prepush`
234
-
- if the code can be built running npm run build
235
-
- if all the tests pass
251
+
-to check if the code can be built running `npm run build`
252
+
-to check if all tests pass
236
253
237
254
## Credits
238
-
[https://github.com/alexjoverm/typescript-library-starter](https://github.com/alexjoverm/typescript-library-starter) For the awesome project which helps to scaffold, develop and build a typescript library project
239
-
[https://github.com/ryanfitz/vogels](https://github.com/ryanfitz/vogels) - To get an idea on how to build the chainable api
240
-
[http://densebrain.github.io/typestore/](http://densebrain.github.io/typestore/) - Thats where the base idea on how to implement the model decorators came came from
255
+
-[https://github.com/alexjoverm/typescript-library-starter](https://github.com/alexjoverm/typescript-library-starter) For the awesome project which helps to scaffold, develop and build a typescript library project
256
+
-[https://github.com/ryanfitz/vogels](https://github.com/ryanfitz/vogels) - To get an idea on how to build the chainable api
257
+
-[http://densebrain.github.io/typestore/](http://densebrain.github.io/typestore/) - Thats where the base idea on how to implement the model decorators came came from
241
258
242
259
## Contributors
243
260
Made with :heart: by [@michaelwittwer](https://github.com/michaelwittwer) and all these wonderful contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
0 commit comments