Get

This endpoint allows you to retrieve a list of documents from the collection. It supports multiple query parameters for filtering, sorting, pagination, and projection, allowing for highly customizable results.

GET /users
For example, this endpoint fetches the entire list of users

Important

Considering the appropriate permissions for accessing the collection.

For example, these permissions grant everyone access to all data, which is risky and should never be used in production, especially with the users collection!

{
    "permissions": {
        "*": true
    }
}

Filter

You can filter the results using the `q` query parameter, where `q[name]` allows you to filter users based on the name. For example, to get users with the name "mike", you would use:

GET /users?q[name]="mike"

if you want to filter users with the name "mike" or "john":

GET /users?q[name]="mike"&q[name]="john"

if you want to filter users with regex, you can use the `$regex` operator. For example, to get users with names that contains "m", you would use:

GET /users?q[name][$regex]=m
consider case sensitivity when using regex. By default, regex queries are case-sensitive. To perform a case-insensitive search, you can use &q[name][$options]=i

The q parameter can be used to filter based on any field in the collection. You can use operators like $eq, $ne, $gt, $lt, $gte, and $lte for more complex queries.

GET /users?q[balance][$gt]=200
            
// result
[
    {
      "_id": "507f1f77bcf86cd799439011",
      "name": "Alice",
      "balance": 250
    },
    {
      "_id": "507f1f77bcf86cd799439012",
      "name": "Bob",
      "balance": 300
    },
    {
      "_id": "507f1f77bcf86cd799439013",
      "name": "Charlie",
      "balance": 500
    },
    {
      "_id": "507f1f77bcf86cd799439014",
      "name": "Mike",
      "balance": 350
    },
    {
      "_id": "507f1f77bcf86cd799439015",
      "name": "John",
      "balance": 400
    }
  ]

Sort

The results can be sorted using the `sort` query parameter. For example, to sort the users by their `createdAt` field in descending order, you can use:

GET /users?sort[createdAt]=-1

Pagination

Pagination can be controlled using `skip` and `limit` query parameters. For example, to skip the first 10 users and limit the results to 5 users, you can use:

GET /users?skip=10&limit=5

Projection

You can specify which fields to include in the results by using the `project` query parameter. For example, to only return the `name` field for each user, you can use:

GET /users?project=["name"]

Info

Considering you can use all of these parameters together.

Edit this page on Github
© 2025 kav3.com. Crafted with and dedication.