From e7d3a083dde1daea13bc51f01a30c9719fe55cda Mon Sep 17 00:00:00 2001 From: Dyllan To Date: Fri, 14 Aug 2020 10:02:17 -0700 Subject: [PATCH 1/2] Add support for setting `schema` in hook params --- lib/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 89cbc1e..f688836 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,7 +64,8 @@ class Service extends AdapterService { // NOTE (EK): We need this method so that we return a new query // instance each time, otherwise it will reuse the same query. db (params = {}) { - const { knex, table, schema, fullName } = this; + const { knex, table, fullName } = this; + const schema = params.schema || this.schema; if (params.transaction) { const { trx, id } = params.transaction; debug('ran %s with transaction %s', fullName, id); From 522caf3cc2bc110dc030a476fcfaa7d601422d35 Mon Sep 17 00:00:00 2001 From: Dyllan To Date: Fri, 14 Aug 2020 10:14:53 -0700 Subject: [PATCH 2/2] Document `schema` parameter --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c6557a..420eb81 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,10 @@ __Options:__ Returns a KnexJS query with the [common filter criteria](https://docs.feathersjs.com/api/databases/querying.html) (without pagination) applied. -### params.knex - -When making a [service method](https://docs.feathersjs.com/api/services.html) call, `params` can contain an `knex` property which allows to modify the options used to run the KnexJS query. See [customizing the query](#customizing-the-query) for an example. +### Params Operators +When making a [service method](https://docs.feathersjs.com/api/services.html) call, `params` can contain: +- **`knex`** - Modifies the options used to run the KnexJS query. See [customizing the query](#customizing-the-query) for an example. +- **`schema`** - Database schema to use with the query (e.g. `public`) See [`withSchema`](http://knexjs.org/#Builder-withSchema) documentation. Overrides service's `schema` option. ## Example