Comments (7)
Thanks. I'll just stick with v2 for the time being, then!
from dynamodb-onetable.
Update: The AWS SDK for JavaScript has prioritized development of DocumentClient for DynamoDB in v3, and an experimental PR can be viewed at aws/aws-sdk-js-v3#2031
from dynamodb-onetable.
Currently OneTable requires the AWS V2 SDK and utilizes DocumentClient. We're monitoring the discussion re V3 & DocumentClient. We definitely want to support V3 but would rather not have to write mapping that emulates DocumentClient ourselves, but we will do that if required. My hope is that the community pressure will force some kind of better DocumentClient upgrade path for V3 by AWS. Failing that in the short term, we will provide an upgrade path.
Since V3 is brand new, it will take a little while for the dust to settle.
from dynamodb-onetable.
In parallel with the AWS DocumentClient PR, we're prototyping V3 support here.
Progressing well and will post updates here.
Our plan is to support both V2 and V3 in the one code base. The V3 support will provide a helper class which will import the required DynamoDB V3 classes and transparently integrate the marshall / unmarshall into and out of Javascript objects.
from dynamodb-onetable.
Okay, got the basic AWS SDK V3 support working. Really not too bad. The marshall / unmarshall support does most of the heavy lifting.
@trivikr I still believe that V3 DocumentClient is probably worthwhile for the general developer so they can more easily upgrade to V3. However, for OneTable, there are performance benefits in going directly to the V3 APIs. So we'll offer both options.
V3 support looks like this:
import {Model, Table} from 'dynamodb-onetable'
import Dynamo from 'dynamodb-onetable/Dynamo'
const table = new Table({
dynamo: new Dynamo(params),
name: 'MyTable',
schema: MySchema,
})
With this configuration, all OneTable APIs work the same as for AWS V2.
For comparison using AWS V2:
import DynamoDB from 'aws-sdk/clients/dynamodb'
import {Model, Table} from 'dynamodb-onetable'
const table = new Table({
client: new DynamoDB.DocumentClient(params),
name: 'MyTable',
schema: MySchema,
})
In the V3 support, the OneTable Dynamo class is a helper which constructs the V3 DynamoDBClient instance for the given params
. The Dynamo helper class separates the dependencies for V3 and will be not-bundled for V2 users. It imports 11 DynamoDBClient commands and wraps these for use by OneTable. The marshall and unmarshall routines are also imported from @aws-sdk/util-dynamodb and passed into OneTable to use transparently.
I know having a helper class import 11 methods defeats perfect tree shaking, but the benefit in a terse interface I believe outweighs shaking a few more bytes that are probably going to be used in any real app anyway.
If you want to construct the DynamoDBClient instance yourself with V3, pass in as new Dynamo({client}).
import DynamoDBClient from '@aws-sdk/client-dynamodb'
import {Model, Table} from 'dynamodb-onetable'
import Dynamo from 'dynamodb-onetable/Dynamo'
const client = new DynamoDBClient(params)
const table = new Table({
dynamo: new Dynamo({client}),
name: 'MyTable',
schema: MySchema,
})
from dynamodb-onetable.
We've cleaned up the API a little by requiring the user to always pass in a DocumentClient or V3 DynamoDBClient instance.
Running through our test suite now. Looks pretty interchangeable with V2 and V3. No user app code that uses OneTable needs changing after the initialization.
import {Table} from 'dynamodb-onetable'
// V2
import DynamoDB from 'aws-sdk/clients/dynamodb'
const client = new DynamoDB.DocumentClient({...})
// V3
import {DynamoDBClient} from '@aws-sdk/client-dynamodb'
import Dynamo from 'dynamodb-onetable/Dynamo'
const client = new Dynamo({client: new DynamoDBClient({...})})
// V2 or V3
const table = new Table({
client: client,
name: 'MyTable',
schema: MySchema,
})
Tagging: @trivikr, @jpet710122
from dynamodb-onetable.
Supported added in 0.7.0 released.
from dynamodb-onetable.
Related Issues (20)
- Metrics.d.ts should not include function interfaces declared as 'async' HOT 7
- Improve: Prohibit the removal of nested object required fields. HOT 1
- Feature: Across entities query HOT 3
- Empty strings are filtered out HOT 2
- Cannot resolve type when ESM HOT 3
- Compound global index not updated if only 1 of 2 properties passed to the update function HOT 1
- Updating unique template field does not remove unique record HOT 2
- "CredentialsProviderError: The SSO session associated with this profile has expired" in "overview" sample... HOT 2
- Create method does not create the sort key if one attribute is undefined HOT 4
- Connecting OneTable to a local dynamodb instance
- Support for Mapped Types HOT 1
- Please Help: Update Problem (referenced attribute) HOT 3
- OneSchema type for getCurrentSchema() not set HOT 2
- Update operation does not remove object from array HOT 1
- Help: retrieving items by GSI1 HOT 1
- nested props are not getting mapped correctly with map attribute
- Getting error while update on object that contains undefined attribute value in it. HOT 2
- Cannot Transparently Pass On JSON String From Previously Unncrypted Field HOT 1
- queryItems requires { hidden:true } to support groupByType for AWS SDK v3 HOT 4
- Duplicate Update Allowed for Scoped Unique Field HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamodb-onetable.