You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+111-3Lines changed: 111 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,6 @@ Simply run `npm install --save feathers-hooks-jsonapify` and you're good to go!
10
10
11
11
## Usage
12
12
13
-
> **Important:** As of version 0.1.0, this hook is intended to use with Sequelize. Further versions will move the coupling code to hook configurations.
14
-
15
13
This hook is intended to use with `feathers-rest`, since it'll convert that provider's response to a JSON-API compliant document.
16
14
17
15
Require the hook:
@@ -46,9 +44,11 @@ app.hooks({
46
44
47
45
### Relationships
48
46
47
+
*Available since: `v0.1.4`*
48
+
49
49
`feathers-hooks-jsonapify` will automatically detect metadata for relationships in the model. It'll create an `included` top-level array in the document when the hook is called via `find`.
50
50
51
-
> Currently working and tested with `belongsTo` and `hasMany` associations.
51
+
> Currently working and tested with `belongsTo` and `hasMany` associations. This feature works only with a Sequelize adapter.
52
52
53
53
#### Example document for a self-referencing model
54
54
@@ -95,6 +95,8 @@ app.hooks({
95
95
96
96
### Pagination
97
97
98
+
*Available since: `v0.1.4`*
99
+
98
100
The hook will also detect if `hook.result.skip`, `hook.result.limit` and `hook.result.total` are available as part of the `feathers-rest` provider. If available, it'll create `first`, `prev`, `next` and `last` links accordingly.
99
101
100
102
The raw pagination data is moved to a `meta` object.
@@ -143,6 +145,112 @@ The raw pagination data is moved to a `meta` object.
143
145
}
144
146
```
145
147
148
+
## Plain Object Serialization (POS) :new:
149
+
150
+
*Available since: `v0.1.8`*
151
+
152
+
Common `Object` arrays can also be `jsonapified` for any custom service's `result`:
153
+
154
+
### Multiple objects
155
+
156
+
```js
157
+
// Sample hook result, with multiple objects, from a `person` custom service.
0 commit comments