Comments (12)
I'll begin taking a look at this, thank you. As a stop gap, the .params() might be useful in the short term.
from electrodb.
Something like this should also work in there interim:
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import {
DynamoDBDocumentClient,
PutCommand,
GetCommand,
ScanCommand,
QueryCommand,
UpdateCommand,
DeleteCommand,
BatchGetCommand,
BatchWriteCommand,
} from '@aws-sdk/lib-dynamodb'
const clientV3 = DynamoDBDocumentClient.from(new DynamoDBClient({}));
class DocumentClientWrapper {
client: DynamoDBDocumentClient;
constructor(client: DynamoDBDocumentClient) {
this.client = client;
}
get(params: any) {
return {
promise: async () => {
const command = new GetCommand(params);
return this.client.send(command);
}
}
}
put(params: any) {
return {
promise: async () => {
const command = new PutCommand(params);
return this.client.send(command);
}
}
}
update(params: any) {
return {
promise: async () => {
const command = new UpdateCommand(params);
return this.client.send(command);
}
}
}
delete(params: any) {
return {
promise: async () => {
const command = new DeleteCommand(params);
return this.client.send(command);
}
}
}
batchWrite(params: any) {
return {
promise: async () => {
const command = new BatchWriteCommand(params);
return this.client.send(command);
}
}
}
batchGet(params: any) {
return {
promise: async () => {
const command = new BatchGetCommand(params);
return this.client.send(command);
}
}
}
scan(params: any) {
return {
promise: async () => {
const command = new ScanCommand(params);
return this.client.send(command);
}
}
}
query(params: any) {
return {
promise: async () => {
const command = new QueryCommand(params);
return this.client.send(command);
}
}
}
createSet(value: any) {
if (Array.isArray(value)) {
return new Set(value);
} else {
return new Set([value]);
}
}
}
// client compatible with ElectroDB:
const client = new DocumentClientWrapper(clientV3);
from electrodb.
@ShivamJoker @moltar I have just merged and published v3 support in version 1.7.0
! Please let me know if you have any issues when using the v3 client and I will make it priority to resolve your issues 👍
from electrodb.
Pros:
- Future-proofing. The end of support for v2 will probably be announced soon, since v3 has been out for a while. And other languages had already EOS announced.
- Native TypeScript support, without
@types/*
- It is mostly codegen'ed from standard definitions, which ensures that all APIs are compatible
- Modular (use only what you need)
- v2 is a heavy dep (if you bundle) (3MB). In v3, take a few common clients, and it'll be ~ 1-2MB and there is a TON of room for them to improve this still. The code is not yet well optimized for bundling.
Cons:
- Not available in the Lambda environment. (Although this was an anti-pattern anyways, and was not recommended to be used that way.)
- Less stable and less battle-tested.
from electrodb.
Thanks Tyler, I'll give it a shot!
from electrodb.
Any updates on this?
from electrodb.
I have been traveling frequently for the past few weeks and haven't had a chance to get this in. This is still on my radar and I am hoping to have more news on it soon.
from electrodb.
Thanks a lot I'll try it.
Also I am using CDK so should I just make a table and your library will add GSI based on schemas?
from electrodb.
Nice one @tywalch!
I still haven't had a chance to try this package out 🙈
Maybe this will give me a boost!
from electrodb.
Btw, should @aws-sdk/lib-dynamodb
be a peer dep?
Because this will increase bundle sizes for everyone, even if they do not use the v3 SDKs.
These v3 SDKs are quite bloated, unfortunately!
https://bundlephobia.com/package/[email protected]
from electrodb.
@moltar so are there any benefits of using V3 with electrodb? In terms of performance
from electrodb.
from electrodb.
Related Issues (20)
- `create` with `SetAttribute` with no client results in `DynamoDBSet` being passed as param causing error HOT 6
- Query validation error - gt and lte create erroneous filter expression HOT 17
- Unspecified attribute which is used as a pk in a GSI is set to empty string on expression HOT 3
- Incorrect type information when using data() HOT 4
- Batch processing and Unprocessed records clarification
- Feature: Support format specifiers when using numbers in template for composite attributes HOT 14
- GSI using existing attribute as its SK results in query with an erroneous filter expression HOT 3
- Dynamo throws Invalid FilterExpression error on a collection query due to redundant parentheses HOT 10
- Op.NotExists on non PK/SK does not seem to be working with AWS SDK v3 HOT 1
- Sort key ignored for collection with clustered index type HOT 2
- [Feature Request] Surface specific AWSError code HOT 3
- Operator `contains` doesn't support List and Set attributes HOT 2
- `createdAt` is updated as `updatedAt` when I do an upsert on my Entity HOT 2
- Ignore Duplicate Index Composite Attributes Error HOT 1
- BatchPut overwrites timestamp `createdAt` HOT 6
- Map attribute with required property creates undefined when property is not present or empty HOT 2
- Support readonly attributes for rebuilding a composite sort key HOT 7
- Computed attributes ignore `field` property during update HOT 4
- Secondary index keys not updated when using composite attributes from table's primary index HOT 13
- RFC: Add support for namespacing partitions HOT 7
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 electrodb.