-
Notifications
You must be signed in to change notification settings - Fork 0
Routes
The adapter serves the same route pack as dynamodb-toolkit/handler. Routes are rooted at the mount point — use app.use('/planets', middleware) to strip a collection prefix from req.path before the adapter runs.
All requests and responses use JSON. The envelope shape, status codes, and - method-prefix are configurable via options.policy.
| Method | Path | Adapter call | Response |
|---|---|---|---|
| GET | / |
getAll(opts, example, index) |
200 — list envelope |
| POST | / |
post(body) |
204 — no body |
| DELETE | / |
deleteAllByParams(params) |
200 {processed: N} |
| GET | /-by-names |
getByKeys(keys, fields, opts) |
200 — array of items |
| DELETE | /-by-names |
deleteByKeys(keys) |
200 {processed: N} |
| PUT | /-load |
putAll(items) |
200 {processed: N} |
| PUT | /-clone |
cloneAllByParams(params, mapFn) |
200 {processed: N} |
| PUT | /-move |
moveAllByParams(params, mapFn) |
200 {processed: N} |
| PUT | /-clone-by-names |
cloneByKeys(keys, mapFn) |
200 {processed: N} |
| PUT | /-move-by-names |
moveByKeys(keys, mapFn) |
200 {processed: N} |
| GET | /:key |
getByKey(key, fields, opts) |
200 — item, or 404 on miss |
| PUT | /:key |
put({...body, ...key}, {force}) |
204 — no body |
| PATCH | /:key |
patch(key, patch, patchOptions) |
204 — no body |
| DELETE | /:key |
delete(key) |
204 — no body |
| PUT | /:key/-clone |
clone(key, mapFn, {force}) |
204 / 404
|
| PUT | /:key/-move |
move(key, mapFn, {force}) |
204 / 404
|
Unrecognized route shapes (e.g. /a/b/c) pass through to the next Express middleware via next(). Known shapes with an unsupported method return 405 Method Not Allowed.
Paginated list with an envelope and HATEOAS-style prev / next links when more data exists. The envelope keys are data / offset / limit / total / links by default — rename via policy.envelope.
Query parameters:
| Param | Purpose |
|---|---|
offset |
Skip N items. Default 0, minimum 0. Hard-capped by policy.maxOffset (default 100000). |
limit |
Return up to N items. Default 10, clamped to maxLimit (default 100). |
fields |
Projection. Comma-separated dotted paths; see parent wiki for grammar. |
filter |
Filter expression in the toolkit's filter DSL. |
sort |
sort=field for asc, sort=-field for desc. Requires a sortableIndices entry for the field. |
consistent |
Pass true / 1 to enable strong consistency on the underlying read. |
Example response:
{
"data": [
{"name": "earth", "mass": 5.97},
{"name": "mars", "mass": 0.642}
],
"offset": 0,
"limit": 10,
"total": 2
}Create a single item. The request body is the item object; the Adapter's post() path runs hooks (prepare, validateItem) and enforces the partition-key-exists-not constraint. On collision the adapter throws ConditionalCheckFailedException → 409 Consistency by default (see Error handling).
Delete every item that matches the same filter query as GET /. Returns {processed: N} — the number of items actually deleted. Dangerous; often worth gating behind an admin auth policy.
Fetch by key. Order of results mirrors the names list. Missing items are dropped from the response.
Delete by key. Also accepts an array body when the query is absent:
curl -X DELETE http://localhost:3000/planets/-by-names \
-H 'content-type: application/json' \
-d '["pluto","eris"]'Bulk create/replace; body is an array of items. Returns {processed: N}. Use for seed data or reloads.
Clone or move named items. Body may be an array (the names list) or an object (an overlay merged into each cloned item). Both at once requires sending ?names=… in the query and an overlay object in the body.
Clone every item matching the filter. Body is the overlay object merged into each cloned item.
Move every item matching the filter — semantically put(overlay ∪ item); delete(original) per item, chunked into transactions.
Fetch one item. Returns 404 (by default) when the item doesn't exist — configurable via policy.statusCodes.miss.
Create or replace. The URL :key segment is merged into the body so callers don't have to repeat themselves. ?force=true skips the existence check (blind overwrite).
Partial update. Body is a patch object; meta keys (prefix _ by default) carry options:
{
"climate": "temperate",
"_delete": ["retired"],
"_arrayOps": [{"op": "add", "path": "visitors", "value": ["probe-42"]}],
"_separator": "."
}Everything without the _ prefix is treated as a field to set. See parsePatch for the full grammar.
Delete one item. Returns 204 regardless of whether the item existed — use GET first if you need miss detection.
Single-item clone / move. Body is the overlay. Returns 204 on success, 404 (or configured miss status) when the source item didn't exist.
-
Unknown route shape (e.g. three path segments) →
next()so the rest of your Express stack can respond. If nothing else handles it, Express's default 404 fires. -
Known shape, wrong method (e.g.
POST /:key) →405 Method Not Allowedvia the adapter's error path. -
Adapter throws → status + JSON body from
policy.errorBody.