Node.js based forum software built for the modern web
closes #6340
Barış Soner Uşaklıbce640e51485
diff --git a/src/database/mongo/main.js b/src/database/mongo/main.jsindex b8ceaa4f6f..55a29e6ff9 100644--- a/src/database/mongo/main.js+++ b/src/database/mongo/main.js@@ -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) {diff --git a/test/database/keys.js b/test/database/keys.jsindex cdd8cc9ab4..6b187b4e3d 100644--- a/test/database/keys.js+++ b/test/database/keys.js@@ -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);