https://github.com/awslabs/dynamodb-data-mapper-js
A schema-based data mapper for Amazon DynamoDB.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.1%) to scientific vocabulary
Repository
A schema-based data mapper for Amazon DynamoDB.
Basic Info
- Host: GitHub
- Owner: awslabs
- License: apache-2.0
- Language: TypeScript
- Default Branch: master
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/
- Size: 1.22 MB
Statistics
- Stars: 818
- Watchers: 22
- Forks: 107
- Open Issues: 81
- Releases: 0
Metadata Files
README.md
Amazon DynamoDB DataMapper For JavaScript
This repository hosts several packages that collectively make up an object to document mapper for JavaScript applications using Amazon DynamoDB.
Getting started
The @aws/dynamodb-data-mapper package provides
a simple way to persist and load an application's domain objects to and from
Amazon DynamoDB. When used together with the decorators provided by the
@aws/dynamodb-data-mapper-annotations package,
you can describe the relationship between a class and its representation in
DynamoDB by adding a few decorators:
```typescript import { attribute, hashKey, rangeKey, table, } from '@aws/dynamodb-data-mapper-annotations';
@table('table_name') class MyDomainObject { @hashKey() id: string;
@rangeKey({defaultProvider: () => new Date()})
createdAt: Date;
@attribute()
completed?: boolean;
} ```
With domain classes defined, you can interact with records in DynamoDB via an
instance of DataMapper:
```typescript import {DataMapper} from '@aws/dynamodb-data-mapper'; import DynamoDB = require('aws-sdk/clients/dynamodb');
const mapper = new DataMapper({ client: new DynamoDB({region: 'us-west-2'}), // the SDK client used to execute operations tableNamePrefix: 'dev_' // optionally, you can provide a table prefix to keep your dev and prod tables separate }); ```
Supported operations
Using the mapper object and MyDomainObject class defined above, you can
perform the following operations:
put
Creates (or overwrites) an item in the table
typescript
const toSave = Object.assign(new MyDomainObject, {id: 'foo'});
mapper.put(toSave).then(objectSaved => {
// the record has been saved
});
get
Retrieves an item from DynamoDB
typescript
mapper.get(Object.assign(new MyDomainObject, {id: 'foo', createdAt: new Date(946684800000)}))
.then(myItem => {
// the item was found
})
.catch(err => {
// the item was not found
})
NB: The promise returned by the mapper will be rejected with an
ItemNotFoundException if the item sought is not found.
update
Updates an item in the table
```typescript const myItem = await mapper.get(Object.assign( new MyDomainObject, {id: 'foo', createdAt: new Date(946684800000)} )); myItem.completed = true;
await mapper.update(myItem); ```
delete
Removes an item from the table
typescript
await mapper.delete(Object.assign(
new MyDomainObject,
{id: 'foo', createdAt: new Date(946684800000)}
));
scan
Lists the items in a table or index
```typescript for await (const item of mapper.scan(MyDomainObject)) { // individual items will be yielded as the scan is performed }
// Optionally, scan an index instead of the table: for await (const item of mapper.scan(MyDomainObject, {indexName: 'myIndex'})) { // individual items will be yielded as the scan is performed } ```
query
Finds a specific item (or range of items) in a table or index
typescript
for await (const foo of mapper.query(MyDomainObject, {id: 'foo'})) {
// individual items with a hash key of "foo" will be yielded as the query is performed
}
Batch operations
The mapper also supports batch operations. Under the hood, the batch will
automatically be split into chunks that fall within DynamoDB's limits (25 for
batchPut and batchDelete, 100 for batchGet). The items can belong to any
number of tables, and exponential backoff for unprocessed items is handled
automatically.
batchPut
Creates (or overwrites) multiple items in the table
typescript
const toSave = [
Object.assign(new MyDomainObject, {id: 'foo', completed: false}),
Object.assign(new MyDomainObject, {id: 'bar', completed: false})
];
for await (const persisted of mapper.batchPut(toSave)) {
// items will be yielded as they are successfully written
}
batchGet
Fetches multiple items from the table
typescript
const toGet = [
Object.assign(new MyDomainObject, {id: 'foo', createdAt: new Date(946684800000)}),
Object.assign(new MyDomainObject, {id: 'bar', createdAt: new Date(946684800001)})
];
for await (const found of mapper.batchGet(toGet)) {
// items will be yielded as they are successfully retrieved
}
NB: Only items that exist in the table will be retrieved. If a key is not found, it will be omitted from the result.
batchDelete
Removes multiple items from the table
typescript
const toRemove = [
Object.assign(new MyDomainObject, {id: 'foo', createdAt: new Date(946684800000)}),
Object.assign(new MyDomainObject, {id: 'bar', createdAt: new Date(946684800001)})
];
for await (const found of mapper.batchDelete(toRemove)) {
// items will be yielded as they are successfully removed
}
Operations with Expressions
Aplication example
```js import { AttributePath, FunctionExpression, UpdateExpression, } from '@aws/dynamodb-expressions';
const expr = new UpdateExpression();
// given the anotation bellow @table('tableName') class MyRecord { @hashKey() email?: string;
@attribute()
passwordHash?: string;
@attribute()
passwordSalt?: string;
@attribute()
verified?: boolean;
@attribute()
verifyToken?: string;
}
// you make a mapper operation as follows const aRecord = Object.assign(new MyRecord(), { email, passwordHash: password, passwordSalt: salt, verified: false, verifyToken: token, }); mapper.put(aRecord, { condition: new FunctionExpression('attributenotexists', new AttributePath('email') }).then( /* result handler */ ); ```
Table lifecycle operations
createTable
Creates a table for the mapped class and waits for it to be initialized:
typescript
mapper.createTable(MyDomainObject, {readCapacityUnits: 5, writeCapacityUnits: 5})
.then(() => {
// the table has been provisioned and is ready for use!
})
ensureTableExists
Like createTable, but only creates the table if it doesn't already exist:
typescript
mapper.ensureTableExists(MyDomainObject, {readCapacityUnits: 5, writeCapacityUnits: 5})
.then(() => {
// the table has been provisioned and is ready for use!
})
deleteTable
Deletes the table for the mapped class and waits for it to be removed:
typescript
await mapper.deleteTable(MyDomainObject)
ensureTableNotExists
Like deleteTable, but only deletes the table if it exists:
typescript
await mapper.ensureTableNotExists(MyDomainObject)
Constituent packages
The DataMapper is developed as a monorepo using lerna.
More detailed documentation about the mapper's constituent packages is available
by viewing those packages directly.
Owner
- Name: Amazon Web Services - Labs
- Login: awslabs
- Kind: organization
- Location: Seattle, WA
- Website: http://amazon.com/aws/
- Repositories: 914
- Profile: https://github.com/awslabs
AWS Labs
GitHub Events
Total
Last Year
Committers
Last synced: about 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jonathan Eskew | e****j@a****m | 91 |
| Jonathan Eskew | j****n@j****t | 26 |
| Jonathan Eskew | j****w@u****m | 10 |
| sh1n1chi8acker | s****a@j****m | 2 |
| aregier | a****r@r****m | 1 |
| Brandon L | b****h@g****m | 1 |
| CarsonBradshaw | c****w@g****m | 1 |
| Travis Webb | me@t****m | 1 |
| Ofek Bashan | o****y@g****m | 1 |
| Hassan Khan | h****n@u****m | 1 |
| Lucas Badico | l****a@g****m | 1 |
| acheronfail | a****l@g****m | 1 |
| Doug Winter | d****r@i****m | 1 |
| Adam Clark | a****k@g****m | 1 |
| Pieter Raubenheimer | p****r@w****m | 1 |
| Chris | c****s@t****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 79
- Total pull requests: 21
- Average time to close issues: about 1 month
- Average time to close pull requests: 6 months
- Total issue authors: 74
- Total pull request authors: 19
- Average comments per issue: 2.72
- Average comments per pull request: 1.24
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- HHK1 (2)
- hassankhan (2)
- ajhool (2)
- jaiminvaja-cue (2)
- thrixton (2)
- tsheaff (1)
- wakeupmh (1)
- ziggy6792 (1)
- mischuler (1)
- antogyn (1)
- acheronfail (1)
- krishmakochhar (1)
- LucasBadico (1)
- maufarinelli (1)
- krazibit (1)
Pull Request Authors
- jeskew (3)
- aregier (1)
- adamclerk (1)
- sh1n1chi8acker (1)
- dnafication (1)
- adrianpanicek (1)
- ofekray (1)
- matt-downs (1)
- ptejada (1)
- acomagu (1)
- perrin4869 (1)
- christopheranderson (1)
- krazibit (1)
- etiennenoel (1)
- haochang (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 23
-
Total downloads:
- npm 928,582 last-month
- Total docker downloads: 6,364
-
Total dependent packages: 244
(may contain duplicates) -
Total dependent repositories: 1,216
(may contain duplicates) - Total versions: 111
- Total maintainers: 29
npmjs.org: @aws/dynamodb-auto-marshaller
A data marshaller that converts JavaScript types into Amazon DynamoDB AttributeValues
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-auto-marshaller/
- License: Apache-2.0
-
Latest release: 0.7.1
published almost 8 years ago
Rankings
Maintainers (19)
npmjs.org: @aws/dynamodb-data-mapper
A schema-based data mapper for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper/
- License: Apache-2.0
-
Latest release: 0.7.3
published almost 8 years ago
Rankings
Maintainers (18)
npmjs.org: @aws/dynamodb-expressions
Composable expression objects for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-expressions/
- License: Apache-2.0
-
Latest release: 0.7.3
published almost 8 years ago
Rankings
Maintainers (18)
npmjs.org: @aws/dynamodb-data-marshaller
A schema-based data marshaller for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-marshaller/
- License: Apache-2.0
-
Latest release: 0.7.3
published almost 8 years ago
Rankings
Maintainers (18)
npmjs.org: @aws/dynamodb-data-mapper-annotations
Annotations providing easy integration between TypeScript domain objects and the @aws/dynamodb-data-mapper library
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper-annotations/
- License: Apache-2.0
-
Latest release: 0.7.3
published almost 8 years ago
Rankings
Maintainers (18)
npmjs.org: @aws/dynamodb-batch-iterator
Abstraction for DynamoDB batch reads and writes for that handles batch splitting and partial retries with exponential backoff
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-batch-iterator/
- License: Apache-2.0
-
Latest release: 0.7.1
published almost 8 years ago
Rankings
Maintainers (18)
npmjs.org: @aws/dynamodb-query-iterator
Abstraction for DynamoDB queries and scans that handles pagination and parallel worker coordination
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-scan-iterator/
- License: Apache-2.0
-
Latest release: 0.7.1
published almost 8 years ago
Rankings
Maintainers (18)
npmjs.org: @spreen/dynamodb-data-mapper
A schema-based data mapper for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: @spreen/dynamodb-data-mapper-annotations
Annotations providing easy integration between TypeScript domain objects and the @aws/dynamodb-data-mapper library
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper-annotations/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: aws-dynamodb-data-mapper
A schema-based data mapper for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
npmjs.org: @nandangk95/dynamodb-query-iterator
Abstraction for DynamoDB queries and scans that handles pagination and parallel worker coordination
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-scan-iterator/
- License: Apache-2.0
-
Latest release: 0.7.12
published about 3 years ago
Rankings
Maintainers (1)
npmjs.org: aws-dynamodb-expressions
Composable expression objects for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-expressions/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
npmjs.org: @spreen/dynamodb-batch-iterator
Abstraction for DynamoDB batch reads and writes for that handles batch splitting and partial retries with exponential backoff
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-batch-iterator/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: @spreen/dynamodb-expressions
Composable expression objects for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-expressions/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: @spreen/dynamodb-query-iterator
Abstraction for DynamoDB queries and scans that handles pagination and parallel worker coordination
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-scan-iterator/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: @spreen/dynamodb-data-marshaller
A schema-based data marshaller for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-marshaller/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: aws-dynamodb-batch-iterator
Abstraction for DynamoDB batch reads and writes for that handles batch splitting and partial retries with exponential backoff
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-batch-iterator/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
npmjs.org: aws-dynamodb-data-mapper-annotations
Annotations providing easy integration between TypeScript domain objects and the @aws/dynamodb-data-mapper library
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper-annotations/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
npmjs.org: aws-dynamodb-auto-marshaller
A data marshaller that converts JavaScript types into Amazon DynamoDB AttributeValues
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-auto-marshaller/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
npmjs.org: @isotoma/dynamodb-data-mapper
A schema-based data mapper for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper/
- License: Apache-2.0
-
Latest release: 0.4.0
published about 8 years ago
Rankings
npmjs.org: aws-dynamodb-data-marshaller
A schema-based data marshaller for Amazon DynamoDB
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-marshaller/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
npmjs.org: @spreen/dynamodb-auto-marshaller
A data marshaller that converts JavaScript types into Amazon DynamoDB AttributeValues
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-auto-marshaller/
- License: Apache-2.0
-
Latest release: 0.8.1
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: aws-dynamodb-query-iterator
Abstraction for DynamoDB queries and scans that handles pagination and parallel worker coordination
- Homepage: https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-scan-iterator/
- License: Apache-2.0
- Status: unpublished
-
Latest release: 0.7.3-pull-request-167-4
published over 6 years ago
Rankings
Maintainers (1)
Dependencies
- @types/jest ^24 development
- @types/node ^8.0.4 development
- jest ^24 development
- lerna ^3.13 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- aws-sdk ^2.7.0
- @types/jest ^24 development
- @types/node ^8.0.4 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- tslib ^1.9
- @types/jest ^24 development
- @types/node ^8.0.4 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- tslib ^1.9
- utf8-bytes ^0.0.1
- @types/jest ^24 development
- @types/node ^8.0.4 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- @aws/dynamodb-auto-marshaller ^0.7.1
- @aws/dynamodb-batch-iterator ^0.7.1
- @aws/dynamodb-data-marshaller ^0.7.3
- @aws/dynamodb-expressions ^0.7.3
- @aws/dynamodb-query-iterator ^0.7.1
- tslib ^1.9
- @types/jest ^24 development
- @types/node ^8.0.4 development
- @types/uuid ^3.0.0 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- @aws/dynamodb-auto-marshaller ^0.7.1
- @aws/dynamodb-data-mapper ^0.7.3
- @aws/dynamodb-data-marshaller ^0.7.3
- reflect-metadata ^0.1.10
- tslib ^1.9
- uuid ^3.0.0
- @types/jest ^24 development
- @types/node ^8.0.4 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- @aws/dynamodb-auto-marshaller ^0.7.1
- @aws/dynamodb-expressions ^0.7.3
- tslib ^1.9
- utf8-bytes ^0.0.1
- @types/jest ^24 development
- @types/node ^8.0.4 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- @aws/dynamodb-auto-marshaller ^0.7.1
- tslib ^1.9
- @types/jest ^24 development
- @types/node ^8.0.4 development
- aws-sdk ^2.7.0 development
- jest ^24 development
- typedoc ^0.14.0 development
- typescript ^3.4 development
- tslib ^1.9