find
Arguments
Params (required)
As parameter, pass the following object:
collection
: Required, the name of collection you want to work with.query
: query in MongoDB-style query syntax. Optional, defaults to:{}
(match all).limit
: max. number of documents in one page. Optional, defaults to25
. Overridable through options object.page
: page number, starting from 1. Optional, defaults to 1
Example:
Response
Result
It should return an object like below:
If no document found, it should NOT yield error. Instead, it sould return an empty data with total = 0.
total
is the total number of documents found matched with your query. Optional, but strongly recommended to return this value.
Error
In case of error, it'll yield a normal Node error object you can catch through promise easily.
Last updated