Closed csi-lk closed 7 years ago
This can be solved with a conditional check similar to #39. I will look at adding a conditional check to the destroy method that will fail if the item does not exist.
The solution is below. See #53
const Account = dynogels.define('account-email', {
hashKey: 'id',
schema: {
id: Joi.number(),
email: Joi.string().email(),
},
})
Account.destroy(
{ id: '123' },
{ expected: { id: { Exists: true } } },
(err, data) => {
console.log(err) // Conditional Check failed
});
I would say this is expected behavior (without the expected
clause). I can't think of any database that will raise an error if you attempt to delete something that does not exist. Even in a SQL database -- a DELETE
where no records match the WHERE
clause is just a successful no-op.
I'm with @cdhowie this is expected behaviour.
As per title, don't know if intended but was expecting an error if deleting on a hash key that does not exist, instead it silently fails.
Example of bug:
Workaround would be to
ReturnValues: 'ALL_OLD'
and see if data existed to manually throw errorHigh level Example:
Cheers