sensedeep / dynamodb-onetable

DynamoDB access and management for one table designs with NodeJS
https://doc.onetable.io/
MIT License
689 stars 109 forks source link

Batch Request: To await or not await #529

Closed lohrm-stabl closed 4 months ago

lohrm-stabl commented 5 months ago

Describe the bug

In the documentation await is used for building up the batch. In the samples included in this repository not. Which one is correct? Is one more performant/recommended than the other?

To Reproduce

const batch = {};

ORGS.get({id: "stabl"}, { batch });
DEVICES.get({ id: "01HZEJQX97WA8JPYCTKWVDY7YP"}, { batch });

const results = await TABLE.batchGet(batch);

Seems to behave the exact same way as:

const batch = {};

await ORGS.get({id: "stabl"}, { batch });
await DEVICES.get({ id: "01HZEJQX97WA8JPYCTKWVDY7YP"}, { batch });

const results = await TABLE.batchGet(batch);

Expected behavior

The documentation should state what is correct/recommended. The samples should adhere to that.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

mobsense commented 5 months ago

Correct use is to await.

You may be able to get away with not using await on some paths, but it has not been tested to be always true.

Until thoroughly tested, I'd recommend using await.