Routing and Queries

Routes

You can basically use any routes as you want without need to define them, just be sure to make it plural to get the population system work as expected.

Plural routes

GET    /posts
GET    /posts/1
POST   /posts
PUT    /posts/1
PATCH  /posts/1
DELETE /posts/1

Filter by equality

You can filter by any by using field=value, Use . to access deep properties

c
GET /posts?id=1&id=2
GET /comments?author.name=fega

You can use $select to return only the fields that you need.

Advanced filters

You can use different modifiers in order to perform special queries:

Pick fields to return

Paginate

Use $page and optionally $limit to paginate returned data. keep in mind that the first page is 0 `$page=0`

10 items are returned by default

Sort

Add $sort and $order (ascending order by default)

For multiple fields, use the following format:

Count

Use $count to get an answer with the total document count

response:

Advanced queries

Use $query to send a JSON with any mongodb query

Regular Expressions (Regex)

Use $regex to send a regex Query

Coming soon...

Relationships

To include children resources, add $populate

To do the opposite, add parent resources use $fill in the query.

Flags

Sometimes you want to pass some data that are neither queries or filters, to be used in the route logic, permissions or filters. you can use them with query flags:

Geo Filters (Coming Soon)

Last updated

Was this helpful?