Skip to content

Commit

Permalink
docs: update readme with table
Browse files Browse the repository at this point in the history
  • Loading branch information
fratzinger committed Sep 30, 2020
1 parent 6f511d2 commit 389322d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const options = {
service: 'tags',
nameAs: 'tags',
keyHere: 'tagIds',
keyThere: '_id'
keyThere: '_id',
asArray: true, // by default
params: {} // by default
}
}

Expand All @@ -37,6 +39,17 @@ app.service('posts').hooks({
});
```

## Options for include

| **Option** | **Description** |
|------------|-----------------|
| `service` | The service to reference<br><br>**required**<br>**Type:** `{String}` |
| `nameAs` | The property to be assigned to on this entry<br><br>**required**<br>**Type:** `{String}` |
| `keyHere` | The primary or secondary key for this entry<br><br>**required**<br>**Type:** `{String}` |
| `keyThere` | The primary or secondary key for the referenced entry/entries<br><br>**required**<br>**Type:** `{String}` |
| `asArray` | Is the referenced item a single entry or an array of entries?<br><br>**optional - default:** `true`<br>**Type:** `{Boolean}`
| `params` | Additional params to be passed to the underlying service.<br>You can mutate the passed `params` object or return a newly created `params` object which gets merged deeply <br>Merged deeply after the params are generated internally.<br><quote>**ProTip:** You can use this for adding a '$select' property or passing authentication and user data from 'context' to 'params' to restrict accesss</quote><br><br>**optional - default:** `{}`<br>**Type:** `{Object | Function(params, context): undefined|params}` |

## Multiple Populates
```js
const { shallowPopulate } = require('feathers-shallow-populate')
Expand All @@ -47,13 +60,17 @@ const options = {
service: 'tags',
nameAs: 'tags',
keyHere: 'tagIds',
keyThere: '_id'
keyThere: '_id',
asArray: true,
params: {}
},
{
service: 'comments',
nameAs: 'comments',
keyHere: 'commentIds',
keyThere: '_id'
keyThere: '_id',
asArray: true,
params: {}
}
]
}
Expand Down Expand Up @@ -105,7 +122,8 @@ const options = {
nameAs: 'publisher',
keyHere: 'publisherId',
keyThere: 'id',
asArray: false
asArray: false,
params: {}
}
}

Expand Down

0 comments on commit 389322d

Please sign in to comment.