To transform the query params to Strapi's standard filters a request, you can use the `convertRestQueryParams` function from [strapi-utils](../strapi-reference/reference.md#strapiutils).
If you are using a SQL database, calling `buildQuery` will return a [`Bookshelf Query`](https://bookshelfjs.org/api.html) on which you can call other functions (e.g `count`)
#### Mongo database
If you are using a mongo database calling `buildQuery` returns either a [`Mongoose Query`](https://mongoosejs.com/docs/api.html#Query) or a custom query when used with deep filtering.
##### Custom Query
When using the deep filtering feature with mongo, we build an aggregation query to avoid too many round-trips with the mongo DB.
Doing that means we don't get a Mongoose object as a response but instead a plain JS Object. This brings a some issues like no virtual fields available and no Mongoose lifecycles.
To deliver the best possible experience, we decided to rehydrate the Mongoose models, forcing us to override the Mongoose query
```js
const query = buildQuery({
model: Product, // you can use any models from strapi.models or strapi.plugins[pluginName].models
filters: { limit: 10 },
populate: [],
});
```
returns a query with the following functions
-`count` => Returns an integer equal to the number of matching entities
-`lean` => Returns the matching elements as Objects
-`then(onSucces, onFailure)` => Calls the onSucces with an array of Mongoose objects.
-`catch(onError)` => Promise catch
-`group(options)` => Calls the aggregation group function of mongoose