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.
This is a request for discussion about the semantics of
db.get()when a key doesn't exist. Currently, an error with a non-enumerabletypekey is provided for missing keys:produces this output:
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.typefor non-existence isNotFoundError.Would it make more sense to just use
undefinedfor the value and not go through theerrparameter?undefinedis 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.