Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 1.48 KB

querying.md

File metadata and controls

74 lines (55 loc) · 1.48 KB

Querying

In addition to sorting and pagination, data can also be filtered by criteria. Standard criteria can just be added to the query. For example, the following finds all users with the name Alice:

query: {
  name: 'Alice'
}

Additionally, the following advanced criteria are supported for each property.

ProTip: Just like with sorting and pagination you won't want to use these special attributes field names in your documents in your database.

$in, $nin

Find all records where the property does ($in) or does not ($nin) contain the given values. For example, the following query finds every user with the name of Alice or Bob:

query: {
  name: {
    $in: ['Alice', 'Bob']
  }
}

$lt, $lte

Find all records where the value is less ($lt) or less and equal ($lte) to a given value. The following query retrieves all users 25 or younger:

query: {
  age: {
    $lte: 25
  }
}

$gt, $gte

Find all records where the value is more ($gt) or more and equal ($gte) to a given value. The following query retrieves all users older than 25:

query: {
  age: {
    $gt: 25
  }
}

$ne

Find all records that do not contain the given property value, for example anybody not age 25:

query: {
  age: {
    $ne: 25
  }
}

$or

Find all records that match any of the given objects. For example, find all users name Bob or Alice:

query: {
  $or: [
    { name: 'Alice' },
    { name: 'Bob' }
  ]
}