Skip to content

Commit 9903394

Browse files
committed
Prepare 0.2.0 release
1 parent dc2015f commit 9903394

File tree

4 files changed

+46
-51
lines changed

4 files changed

+46
-51
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
isotopes-0.2.0 (2018-07-29)
2+
3+
* Added support for multi-attribute values
4+
15
isotopes-0.1.1 (2018-07-27)
26

37
* Fixed entrypoint and typings

README.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ import { Isotope } from "isotopes"
3838

3939
TypeScript typings are provided as part of the package, so no need to install a
4040
separate package. However, the [aws-sdk][3] is listed as a peer dependency, so
41-
make sure it is installed. Note that when you run *Isotopes* from within AWS
42-
Lambda the SDK is already installed.
41+
make sure it is installed. When you run *Isotopes* from within AWS Lambda the
42+
SDK is already installed.
4343

4444
[3]: https://www.npmjs.com/package/aws-sdk
4545

4646
## Usage
4747

48-
> Note: the following instructions are intended for usage from TypeScript. You
48+
> Note: the following instructions are intended for usage with TypeScript. You
4949
can also use *Isotopes* from plain JavaScript by omitting all typings from
5050
the examples, but what's the point? [Learn TypeScript][4], it's awesome!
5151

@@ -63,19 +63,20 @@ export interface Task {
6363
cpus: number /* Number of CPUs */
6464
memory: number /* Reserved memory */
6565
command?: string /* Command override */
66-
}
66+
},
67+
tags: string[] /* Tags for categorization */
6768
}
6869
```
6970

7071
Every type that is handled by *Isotopes* must contain a unique identifier which
71-
is used for item identification. The identifier *should* be on the first level
72-
of the type to be stored, all other variables can be arbitrarily nested. Next,
73-
create an isotope for the type, e.g. for a SimpleDB domain named `tasks`:
72+
is used as an item name. The item name *should* be on the first level of the
73+
type to be stored, all other variables can be arbitrarily nested. Next, create
74+
an isotope for the type, e.g. for a SimpleDB domain named `tasks`:
7475

7576
``` ts
7677
const tasks = new Isotope<Task>({
77-
domain: "tasks",
78-
key: "id"
78+
domain: "tasks", /* SimpleDB domain name */
79+
key: "id" /* SimpleDB item name (primary key) */
7980
})
8081
```
8182

@@ -84,7 +85,7 @@ const tasks = new Isotope<Task>({
8485
or destroy domains by itself. However, [Terraform][5] is an excellent tool
8586
for this.
8687

87-
Suppose we have the following item:
88+
Now, suppose we have the following item:
8889

8990
``` ts
9091
const task: Task = {
@@ -94,13 +95,17 @@ const task: Task = {
9495
image: "busybox",
9596
cpus: 2,
9697
memory: 2048
97-
}
98+
},
99+
tags: [
100+
"TAG_1",
101+
"TAG_2"
102+
]
98103
}
99104
```
100105

101-
We can persist, retrieve and delete items of our defined type from the isotope
102-
by using a simple API, cleverly omitting all the boilerplate that is normally
103-
necessary for interfacing with SimpleDB. Persist an item:
106+
We can persist, retrieve and delete items from the isotope by using a simple
107+
API, cleverly omitting all the boilerplate that is normally necessary for
108+
interfacing with SimpleDB. Persist an item:
104109

105110
``` ts
106111
await tasks.put(task) // => void
@@ -161,21 +166,22 @@ try {
161166
### Persistence, retrieval and deletion of partial types
162167

163168
By default, *Isotopes* forces only valid entries to be written to SimpleDB which
164-
means that all non-optional fields need to be defined in the payload. However,
165-
SimpleDB allows reading and writing of partial attribute values, so it might be
166-
desirable in some cases to loosen that restriction and allow partial reads and
167-
writes. *Isotopes* allows both configurations through simple generic typing.
169+
means that all non-optional fields need to be defined in the payload (otherwise
170+
the TypeScript compiler will moan). However, SimpleDB allows reading and writing
171+
of partial attribute values, so it might be desirable in some cases to loosen
172+
that restriction and allow partial reads and writes. *Isotopes* allows both
173+
configurations through simple generic typing.
168174

169175
``` ts
170176
class Isotope<
171177
T extends {}, /* Data type */
172178
TPut extends Partial<T> = T, /* Data type expected by PUT operation */
173-
TGet extends Partial<T> = TPut /* Data type returned by PUT operation */
179+
TGet extends Partial<T> = TPut /* Data type returned by GET operation */
174180
> {}
175181
```
176182

177183
The first type argument is mandatory and defines the base type. The second
178-
and third type arguments can be used to specify what exact types PUT and GET
184+
and third type arguments can be used to specify what exact types `PUT` and `GET`
179185
operations return but normally they are equal to the base type.
180186

181187
Allow complete values only:
@@ -184,24 +190,24 @@ Allow complete values only:
184190
new Isotope<Task>(...)
185191
```
186192

187-
Allow partial values in PUT and GET operations:
193+
Allow partial values in `PUT` and `GET` operations:
188194

189195
``` ts
190196
new Isotope<Task, Partial<Task>>(...)
191197
```
192198

193-
Allow partial values in GET operations only:
199+
Allow partial values in `GET` operations only:
194200

195201
``` ts
196202
new Isotope<Type, Type, Partial<Type>>(...)
197203
```
198204

199-
Furthermore, SELECT operations are assumed to return the same type as GET
205+
Furthermore, `SELECT` operations are assumed to return the same type as `GET`
200206
operations. Since this may be different on a case-by-case basis (depending on
201-
the specific SQL query), it may be overriden on a per-query basis:
207+
the specific SQL query), it may be overridden on a per-query basis:
202208

203209
``` ts
204-
tasks.select<Partial<Task>>(...)
210+
await tasks.select<Partial<Task>>(...)
205211
```
206212

207213
### Encoding
@@ -216,7 +222,7 @@ const tasks = new Isotope<Task>({
216222
})
217223
```
218224

219-
#### JSON <small>default, recommended</small>
225+
#### JSON (recommended)
220226

221227
> `options.format.encoding: "json"`
222228
@@ -230,13 +236,15 @@ whereas numbers and booleans are written literally:
230236
{ "Name": "active", "Value": "true" },
231237
{ "Name": "props.image", "Value": "\"busybox\"" },
232238
{ "Name": "props.cpus", "Value": "2" },
233-
{ "Name": "props.memory", "Value": "2048" }
239+
{ "Name": "props.memory", "Value": "2048" },
240+
{ "Name": "tags[]", "Value": "\"TAG_1\"" },
241+
{ "Name": "tags[]", "Value": "\"TAG_2\"" }
234242
]
235243
}
236244
```
237245

238-
If you don't plan to use the SimpleDB domain from a non-*Isotope* environment,
239-
you should always stick with JSON-encoding because it is more safe than text
246+
If you don't plan to use the SimpleDB domain from a non-*Isotope* client, you
247+
should always stick with JSON-encoding because it is more safe than text
240248
encoding and comes with no limitations.
241249

242250
#### Text
@@ -253,7 +261,9 @@ as literals so they are written without quotes:
253261
{ "Name": "active", "Value": "true" },
254262
{ "Name": "props.image", "Value": "busybox" },
255263
{ "Name": "props.cpus", "Value": "2" },
256-
{ "Name": "props.memory", "Value": "2048" }
264+
{ "Name": "props.memory", "Value": "2048" },
265+
{ "Name": "tags[]", "Value": "TAG_1" },
266+
{ "Name": "tags[]", "Value": "TAG_2" }
257267
]
258268
}
259269
```

package-lock.json

Lines changed: 1 addition & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "isotopes",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Serverless and typed object store built on top of AWS SimpleDB",
55
"keywords": [
66
"aws",

0 commit comments

Comments
 (0)