1.1.0 • Published 5 months ago

dynamobase v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

DynamoBase

Query DynamoDB like MongoDB. A lightweight JSON model that simplifies DynamoDB's obscure query operations. It retains all original parameters and supports DynamoDB versions and future upgrades.

What can be done:

  1. Query condition is JSON format
  2. No need to consider complex expressions no matter query or update
  3. Column names can be any reserved keywords
  4. Return the correct int, float, number types

What can't be done:

Create, modify, and drop DynamoDB tables

Install

npm i dynamobase
yarn add dynamobase

Configuration

import { dynamobase_config } from "dynamobase";
dynamobase_config({ region: "us-east-1" })

Use

Basic try

import { get_first, get_item, get_items } from "dynamobase";
const result = await get_first({
  TableName: "table_name",
  query: { _id: "xxxx-xxxx" },
  ScanIndexForward: false,
});

APIs

All "GET" operations support: = | <= | < | >= | > | begins_with | between

get_item

parameters

NameTypeExampledescription
querydict{"id": 123}query must be primary key (and sort key)

return: Dict or None

get_items

parameters: The parameters supported by get_items and get_first are as follows:

NameTypedescription
querydictquery can be primary key or GSI columns
filterdictany fields and any values
IndexNameStringrequired if query is GSI or LSI
SelectString
AttributesToGetList
Limitint
ConsistentReadString
KeyConditionsdict
QueryFilterdict
ConditionalOperatorString
ScanIndexForwardboolean
ExclusiveStartKeydict
ReturnConsumedCapacityString
ProjectionExpressionString
FilterExpressionboto3.dynamodb.conditions.Attr

return: List or None

get_first

parameters: same as get_items

return: Dict or None

put_item

parameters

NameTypeExample
Itemdict{"id": 123}

update_item

parameters

NameTypeExampledescription
querydict{"id": 123}query must be primary key (and sort key)
Itemdict{"field": "some value"}--

delete_item

parameters

NameTypeExampledescription
querydict{"id": 123}query must be primary key (and sort key)

DynamoDB docs

DynamoDB Query Parameters

1.1.0

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago