dehaze

Using Multiple Operations

Multiple operations can be used together in the same query. For example, you can filter the results, sort and limit them all in a single query.

Example: Fetch a list of trainers and only their first two Water type pokemons sorted by their name:

query {
  trainers {
    _id
    name
    pokemons(
      where: {type: "Water"},
      sort: {name: 1},
      limit: 2
    ) @mongo {
      id
      name
    }
  }
}
const whereClause = cond("type", "==", "Water")

const { status, data } = await db.get("pokemons")
  .where(whereClause)
  .sort("name")
  .limit(2)
  .apply()

Have a technical question?

Improve the docs!