Replies: 3 comments 2 replies
-
This is one thing I also have to figure out before switching over to a single table design. I think it would be good to have a static function on the Something like this maybe: const Task = new Entity({
model: {
entity: "task",
version: "1",
service: "taskapp",
},
attributes: {
// ...
},
indexes: {
// ...
},
}, { table, client });
const Book = new Entity({
model: {
entity: 'book',
version: '1',
service: 'store'
},
attributes: {
// ...
},
indexes: {
// ...
}
}, { client, table });
function main(event: DynamoDBStreamEvent) {
const parsed = event.Records
.map(record => DynamoDB.Converter.unmarshall(record.dynamodb.NewImage))
.map(item =>
Entity.fromImage( //> returns an instance of Task or Book
{ Item: item },
[Task, Book] // pass all your entities here
)
)
console.log(parsed)
} |
Beta Was this translation helpful? Give feedback.
-
Hi @barqco 👋 The |
Beta Was this translation helpful? Give feedback.
-
I am working right now actually on methods to help translate:
@zirkelc a |
Beta Was this translation helpful? Give feedback.
-
Hi,
Love the library, I have a quick question on how to semantically handle dynamodb streams. I know about the parse section of the documentation
The sample code shows the following:
However, I want to create a generic dynamostream handler where I am not sure yet what the Entity type of the event record is. So I can't parse since I don't know what entity it is yet. There is a private field called
__edb_e__
, that does show up in the new image. I am wondering if it is advisable to rely on this, or if there are plans in the future to expose something that will "get" the entity type from a potential JSON object.My Code looks something like this:
I'm hoping to use Zod and create a switch statement
let me know what you think!
Beta Was this translation helpful? Give feedback.
All reactions