v1.18.x
Barış Soner Uşaklı 7 years ago
parent ee50a340cd
commit bce640e514

@ -66,7 +66,21 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
module.getObjectField(key, 'data', callback);
module.getObject(key, function (err, objectData) {
if (err) {
return callback(err);
}
// fallback to old field name 'value' for backwards compatibility #6340
var value = null;
if (objectData) {
if (objectData.hasOwnProperty('data')) {
value = objectData.data;
} else if (objectData.hasOwnProperty('value')) {
value = objectData.value;
}
}
callback(null, value);
});
};
module.set = function (key, value, callback) {

@ -27,6 +27,14 @@ describe('Key methods', function () {
});
});
it('should return null if key does not exist', function (done) {
db.get('doesnotexist', function (err, value) {
assert.ifError(err);
assert.equal(value, null);
done();
});
});
it('should return true if key exist', function (done) {
db.exists('testKey', function (err, exists) {
assert.ifError(err);

Loading…
Cancel
Save