Stack9 Query Object
Stack9 Query Object is the object that Stack9 uses to query the entities from Stack9
Params | Type | Description |
---|---|---|
$withRelated | string[] | String array to set the entity's relationships to come with in the query |
$select | string[] | String array with the properties to retrieve from the query |
$where | Stack9CriteriaObject | Object that represents the where clause in the query |
$sort | SortObject | Object that represents the order by clause in the query [property: string]: 1 or -1 |
Stack9 Criteria Object
property: value
Specifies equality condition. This operator matches documents where the value of a field equals the specified value.
// e.g. Finding the user with specific credential
{
"$where": {
"email": "johndoe@domain.com.au",
"password": "encodedPassword"
}
}
$like
Specifies like condition. This operator matches documents where the value of a field contains the specified value.
// e.g. Finding the all the users with gmail account
{
"$where": {
"email": {
"$like": "%@gmail.com"
}
}
}
$gte/$gt
Specifies Greater than condition. $gt
selects those documents where the value of the field is greater than the specified value.
// e.g. Get everyone who was born in 2000 or greater.
{
"$where": {
"dob": { "$gt": "1999-12-31" }
}
}
Specifies Greater than or equals condition. $gte
selects those documents where the value of the field is greater than or equals to the specified value.
// e.g. Get everyone who was born in 2000 or greater.
{
"$where": {
"dob": { "$gte": "2000-01-01" }
}
}
$lte/$lt
Specifies Lower than condition. $lt
selects those documents where the value of the field is lower than the specified value.
// e.g. Get everyone who was born before 2000.
{
"$where": {
"dob": { "$lt": "2000-01-01" }
}
}
Specifies Lower than or equal condition. $lte
selects those documents where the value of the field is lower than or equals to the specified value.
// e.g. Get everyone who was born before 2000.
{
"$where": {
"dob": { "$lte": "1999-12-31" }
}
}
$ne
Specifies not equal condition. $ne
selects those documents where the value of the field is not equal to null
.
{
"where": {
"user_id": { "$ne": null }
}
}
$or
Specifies a boolean condition. $or
selects those documents where at least the value of one of the fields is true
.
{
"where": {
"$or": [{ "is_customer": true }, { "is_importer": true }]
}
}
$and
Specifies a boolean condition. $and
selects those documents where the value of all fields are true
.
{
"where": {
"$and": [{ "is_customer": true }, { "is_importer": true }]
}
}