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 = {};
fields.forEach((field) => {
field = helpers.fieldToString(field);
if (field) {
data[field] = 1;
}
});
const item = await module.client.collection('objects').findOne({ _key: key }, { projection: data });

@ -406,6 +406,11 @@ describe('Hash methods', () => {
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();
});
});
it('should not error if one field is falsy', async () => {
const values = await db.isObjectFields('hashTestObject', ['name', '']);
assert.deepStrictEqual(values, [true, false]);
});
});
describe('deleteObjectField()', () => {

Loading…
Cancel
Save