Skip to content

Commit c124eb8

Browse files
author
Vinay Padmanabhi
committed
fix(total_count_performance): update readme
1 parent 45fb9e8 commit c124eb8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,33 @@ server.route({
232232
});
233233
```
234234

235+
### include option - use this option to restrict counting to only the included items in the list
236+
237+
```js
238+
const Book = require('../models/book');
239+
240+
server.route({
241+
method: 'GET',
242+
path: '/books',
243+
config: {
244+
plugins: {
245+
queryFilter: { enabled: true },
246+
totalCount: {
247+
include: ['approximate'],
248+
model: Book
249+
}
250+
},
251+
handler: (request, reply) => {
252+
return new Book().filter(request.query.filter, request.auth.credentials)
253+
.fetchAll()
254+
.then((books) => {
255+
reply({ data: books });
256+
});
257+
}
258+
}
259+
});
260+
```
261+
235262
### Request
236263

237264
```bash

0 commit comments

Comments
 (0)