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
This is the documentation for the new version of dynamo-easy released as a scoped package using the namespace
12
-
@shiftcoders (@shiftcoders/dynamo-easy). If you still want to use the 0.0.x version you can
13
-
by installing the old version `npm install dynamo-easy` (https://github
14
-
.com/shiftcode/dynamo-easy/releases/tag/v0.10
15
-
.1)
16
-
17
11
Abstracts away the complexity of the low level aws dynamosdk. Provides an easy to use fluent api to for requests and supports typescript decorators,
18
12
to define some metadata for your models. You don't need to care about the mapping of javascript types to their dynamo types any more. We got you covered.
19
13
@@ -22,6 +16,53 @@ Checkout the full technical api documentation [here](https://shiftcode.github.io
22
16
Built with :heart: by [shiftcode](https://www.shiftcode.ch).
23
17
24
18
# Get Started
19
+
20
+
## Prerequisite
21
+
22
+
### Typescript Metadata
23
+
24
+
#### Reflection API
25
+
26
+
> ⚠ The reflect-metadata polyfill should be imported only once in your entire application because the Reflect object is
27
+
mean to be a global singleton.
28
+
29
+
Install the reflect-metadata polyfill.
30
+
31
+
```
32
+
npm install reflect-metadata --save
33
+
```
34
+
35
+
The type definitions for reflect-metadata are included in the npm package.
36
+
You need to add the following reference to the types field in your [tsconfig.json](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types):
37
+
38
+
```
39
+
"types": ["reflect-metadata"]
40
+
```
41
+
42
+
Finally, import reflect-metadata in some entry file in your application.
43
+
44
+
```
45
+
import "reflect-metadata"
46
+
```
47
+
48
+
#### Decorators
49
+
50
+
51
+
We need to enable the two experimental features to work with decorators, add this to your tsconfig.json:
52
+
53
+
```
54
+
"experimentalDecorators": true
55
+
"emitDecoratorMetadata": true
56
+
```
57
+
58
+
#### Other
59
+
Also make sure to install the other peer dependencies of @shiftcoders/dynamo-easy.
60
+
61
+
62
+
## First Sample
63
+
64
+
When all the setup work is done, define your first model and create a dynamo store to execute actions on the dynamoDB.
65
+
25
66
```typescript
26
67
@Model()
27
68
classPerson{
@@ -57,16 +98,9 @@ dynamoStore.scan()
57
98
58
99
```
59
100
60
-
Want to use this library with Angular (>4) [checkout our angular-service](TODO).
61
-
62
101
# Decorators
63
102
Decorators are used to add some metadata to our model classes, relevant to our javascript-to-dynamo mapper.
64
103
65
-
This is an experimental feature and requires to set the following typescript compiler options:
66
-
67
-
- "experimentalDecorators": true
68
-
- "emitDecoratorMetadata": true
69
-
70
104
Additionally we rely on the reflect-metadata (https://www.npmjs.com/package/reflect-metadata) library for reflection api.
71
105
72
106
To get started with decorators just add a [@Model()](https://shiftcode.github.io/dynamo-easy/modules/_decorator_impl_model_model_decorator_.html) Decorator to any typescript class.
Copy file name to clipboardExpand all lines: tsconfig.json
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,10 @@
47
47
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
48
48
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
49
49
// "typeRoots": [], /* List of folders to include type definitions from. */
50
-
// "types": [], /* Type declaration files to be included in compilation. */
50
+
"types": [ /* Type declaration files to be included in compilation. */
51
+
"node",
52
+
"reflect-metadata"
53
+
],
51
54
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
52
55
// "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
53
56
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
0 commit comments