feathers-json-patch
Add JSON Patch support to any Feathers database adapter or service.
$ npm install --save feathers-json-patch
Usage
Feathers server
An example using the feathers-memory adapter.
const memoryService = ;const withJsonPatch = ; const service = ; app;
Another example, using service constructor:
const MemoryService = Service;const withJsonPatch = ; const MyService = ; app;
Feathers client
;; const client = ; const id = 1; const message = await client; const newValues = ...message text: 'My updated message!' tags: 'info'; // Generate a JSON patch objectconst diff = ; // Optional check, but no need to send// a patch request if the diff has length == 0if difflength client;
HTTP
PATCH /messages/1 HTTP/1.1Accept: application/json [ { "op": "replace", "path": "/text", "value": "My updated message!" }, { "op": "add", "path": "/tags", "value": ["info"] }] HTTP/1.1 200 OKContent-Type: application/json { "id": 1, "text": "My updated message!", "tags": ["info"]}