-
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
discussionDiscussionDiscussion
Description
This is a request for discussion about the semantics of db.get() when a key doesn't exist. Currently, an error with a non-enumerable type key is provided for missing keys:
db.get('does-not-exist', function (err, value) {
console.log('err=', err);
console.log('err.type=', err.type);
})produces this output:
err= {}
err.type= NotFoundError
The error is not easy to inspect at a glance (a separate issue) and if you want to check for non-existence you've got to remember that the err.type for non-existence is NotFoundError.
Would it make more sense to just use undefined for the value and not go through the err parameter? undefined is already an invalid value to use for storage so it wouldn't conflict with anything unless there are some edge cases for custom valueEncodings I'm not aware of.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
discussionDiscussionDiscussion
Type
Projects
Status
Done