diff --git a/lib/index.js b/lib/index.js index 2b3b349..1aada65 100644 --- a/lib/index.js +++ b/lib/index.js @@ -61,7 +61,7 @@ class Service extends AdapterService { total, limit: filters.$limit, skip: filters.$skip || 0, - data + data: data.map(select(params, this.id)) }; }); diff --git a/test/index.test.js b/test/index.test.js index 20fef79..ce98ec6 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -167,6 +167,24 @@ describe('NeDB Service', () => { await service.remove(mod._id); }); + it('can $select with only id (#100)', async () => { + const mod = await service.create({ + name: 'Modifier', + age: 343 + }); + const data = await service.find({ + query: { + age: 343, + $select: ['_id'] + } + }); + + assert.ok(data[0]._id); + assert.ok(!data[0].name); + + await service.remove(mod._id); + }); + it('allows NeDB modifiers (#59)', async () => { const person = await service.create({ name: 'Modifier',