The operators limit and skip are used for pagination.
limit specifies the number of rows to retain from the result set and skip determines the number of objects to skip (i.e. the offset of the result)
The following are examples of different pagination scenarios:
Example: Fetch the first 5 trainers from the list of all trainers:
query {
trainers(
limit: 5
) @mongo {
_id
name
}
}const { status, data } = await db.get("trainers")
.limit(5)
.apply()
Example: Fetch 5 trainers from the list of all trainers starting from the 6th one:
query {
trainers(
skip: 5,
limit: 5
) @mongo {
_id
name
}
}const { status, data } = await db.get("trainers")
.skip(5)
.limit(5)
.apply()
Example: Fetch first 3 trainers and 2 pokemons of each trainer starting from the 6th one:
query {
trainers(
limit: 3
) @mongo {
_id
name
pokemons(
skip: 5,
limit: 2
) @mongo {
name
}
}
}