From 65c0a6245a9889994011283c187bdab38ed4cc3f Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Tue, 1 Aug 2023 18:09:44 +0000 Subject: [PATCH] feat(app-express): pass partialFilter from body to core for data/_index --- packages/app-express/api/data.test.ts | 8 +++++--- packages/app-express/api/data.ts | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/app-express/api/data.test.ts b/packages/app-express/api/data.test.ts index cab593b5..a7abd66e 100644 --- a/packages/app-express/api/data.test.ts +++ b/packages/app-express/api/data.test.ts @@ -23,8 +23,8 @@ const services: any = { db, id, }), - index: (db: any, name: any, fields: any) => - crocks.Async.Resolved({ ok: true, db, name, fields }), + index: (db: any, name: any, fields: any, partialFilter: any) => + crocks.Async.Resolved({ ok: true, db, name, fields, partialFilter }), query: (db: any, query: any) => crocks.Async.Resolved({ ok: true, db, query }), bulkDocuments: (db: any, body: any) => crocks.Async.Resolved({ ok: true, db, results: body }), listDocuments: (db: any, query: any) => { @@ -374,7 +374,7 @@ Deno.test('data', async (t) => { }) await t.step( - 'should pass db and body name and fields to core', + 'should pass db and body name fields and partialFilter to core', async () => { await harness .start() @@ -384,6 +384,7 @@ Deno.test('data', async (t) => { body: JSON.stringify({ name: 'idx_foo', fields: ['name'], + partialFilter: { type: 'bar' }, }), }) .then((res) => res.json()) @@ -392,6 +393,7 @@ Deno.test('data', async (t) => { assertEquals(body.name, 'idx_foo') assertEquals(body.fields.length, 1) assertEquals(body.fields[0], 'name') + assertEquals(body.partialFilter, { type: 'bar' }) }) ) .finally(async () => await harness.stop()) diff --git a/packages/app-express/api/data.ts b/packages/app-express/api/data.ts index fd10e4fa..efebbd62 100644 --- a/packages/app-express/api/data.ts +++ b/packages/app-express/api/data.ts @@ -73,7 +73,12 @@ export const data = (services: HyperServices) => (app: Server) => { '/data/:db/_index', json(), bindCore(services), - ({ data, params, body }, res) => fork(res, 201, data.index(params.db, body.name, body.fields)), + ({ data, params, body }, res) => + fork( + res, + 201, + data.index(params.db, body.name, body.fields, body.partialFilter), + ), ) app.post(