-
Is there updated documentation on setting up electrodb with aws-sdk v3? I've been unable to get anything to work: Entity file:
Attempting to use this in a controller with
results in But I am passing the client, so not sure what's going on here. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @ktwbc 👋 Here is an example of how you you can use Electro with the v3 client: import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { Entity } from 'electrodb';
const table = 'my-table';
const client = new DynamoDBClient({
region: "us-east-1",
endpoint: 'http://localhost:8000',
});
const thing = new Entity({
model: {
entity: 'thing',
service: 'database',
version: '01'
},
attributes: {
id: {
type: 'string',
},
name: {
type: 'string',
},
description: {
type: 'string',
}
},
indexes: {
record: {
pk: {
field: 'pk',
composite: ['id'],
},
sk: {
field: 'sk',
composite: [],
},
}
}
}, { table, client });
thing.get({ id: '123' }).go()
.then(console.log)
.catch(console.error); |
Beta Was this translation helpful? Give feedback.
-
I got it mostly working, after figuring out I needed to use templates to put this on an existing database (, but am still encountering something strange when trying to do a get() and it's not returning the record. I can attach the logger to the Entity and I see that electrodb is querying the table and returns my record: // logging output
So the "Item" is definitely the record I've queried in that output. yet the result object in my actual code only returns { data: null } which is baffling since the logger clearly shows it retrieved the record.
Tokens.ts
|
Beta Was this translation helpful? Give feedback.
-
Thanks. I am coming from Dynamo-Types ORM and wrote a converter https://github.com/ktwbc/convert-to-electrodb for my model files based on this. Appreciate the help. |
Beta Was this translation helpful? Give feedback.
Hi @ktwbc 👋
Here is an example of how you you can use Electro with the v3 client: