How to handle get method that must return record not found? #578
Replies: 1 comment 1 reply
-
Adding to the above discussion, when a record found it returns this data: But if record not found it returns this data: So this is the default behavior of DynamoDB Toolbox. So we have to check it Item object is undefined. |
Beta Was this translation helpful? Give feedback.
-
When using get method on an entity with key that does not exist, I want to show record not found error.
Sample code:
try {
const data: any = await RootUserEntity.get(key, {
attributes: returnAttributes,
});
----- the data returned is an object -----
-------- how to find record not ? --------
} catch (error: any) {
return error.message;
}
is there a way to solve this?
Beta Was this translation helpful? Give feedback.
All reactions