From 43f9c9d1b82576ac43a2ba0a9f478d9ee9527c8b Mon Sep 17 00:00:00 2001 From: Todd Geist Date: Fri, 11 May 2018 09:41:44 -0700 Subject: [PATCH] Update Readme Add note about passing nedb options client. --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index b5db63f..76c37ea 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,29 @@ app.service('messages').update('someid', { }); ``` +### use of params on client +On client you can't pass anything other than a query as the parameter. So you need to do it like this. + +```js +// client side +app.service('messages').update('someid', { + text: 'This message will be either created or updated' +}, { + query: {nedb: { upsert: true }} +}); +``` +then add a hook to the service to move the nedb options to the params object +```js +ctx => { + const nedb = ctx.params.query.nedb; + if (nedb) { + ctx.params.nedb = nedb; + delete ctx.params.query.nedb; + } + return ctx; +} +``` + ## Example Here is an example of a Feathers server with a `messages` NeDB service that supports pagination and persists to `db-data/messages`: