fix: isObjectField(s) empty field

v1.18.x
Barış Soner Uşaklı 4 years ago
parent ff98f85488
commit 2c22b06feb

@ -156,7 +156,9 @@ module.exports = function (module) {
const data = {}; const data = {};
fields.forEach((field) => { fields.forEach((field) => {
field = helpers.fieldToString(field); field = helpers.fieldToString(field);
data[field] = 1; if (field) {
data[field] = 1;
}
}); });
const item = await module.client.collection('objects').findOne({ _key: key }, { projection: data }); const item = await module.client.collection('objects').findOne({ _key: key }, { projection: data });

@ -406,6 +406,11 @@ describe('Hash methods', () => {
done(); done();
}); });
}); });
it('should not error if field is falsy', async () => {
const value = await db.isObjectField('hashTestObjectEmpty', '');
assert.strictEqual(value, false);
});
}); });
@ -427,6 +432,11 @@ describe('Hash methods', () => {
done(); done();
}); });
}); });
it('should not error if one field is falsy', async () => {
const values = await db.isObjectFields('hashTestObject', ['name', '']);
assert.deepStrictEqual(values, [true, false]);
});
}); });
describe('deleteObjectField()', () => { describe('deleteObjectField()', () => {

Loading…
Cancel
Save