Query Conditional Operators
MVOM supports a number of query operators to use for filtering the results of a query.
All examples on this page are working with a Model
constructed in the following manner:
const schema = new Schema({
description: { type: 'string', path: 1, dictionary: 'DESCRIPTION' },
price: { type: 'number', path: 2, dbDecimals: 2, dictionary: 'PRICE' },
});
const Item = connection.model(schema, 'ITEM');
Equality Operator
The equality operator is $eq
. This operator will find records where the property's value is equal to the provided conditional value.
Example
const items = await Item.find({ price: { $eq: 100 } });
The query which will be executed on the MultiValue database is:
select ITEM with PRICE = "100"
Implicit Equality Operator
When querying for equality, it is not necessary to use the $eq
operator. The following query condition filter object format will implicitly assume equality without the need for specifying the $eq
operator.
{
propertyName: conditionalValue;
}
Example
This example illustrates using the implicit equality syntax to execute the same query as shown using the explicit equality operator.
const items = await Item.find({ price: 100 });
The query which will be executed on the MultiValue database is:
select ITEM with PRICE = "100"
Greater than operator
The greater than operator is $gt
. This operator will find records where the property's value is greater than the provided conditional value.
Example
const items = await Item.find({ price: { $gt: 100 } });
The query which will be executed on the MultiValue database is:
select ITEM with PRICE > "100"
Greater than or equal to operator
The greater than or equal to operator is $gte
. This operator will find records where the property's value is greater than or equal to the provided conditional value.
Example
const items = await Item.find({ price: { $gte: 100 } });
The query which will be executed on the MultiValue database is:
select ITEM with PRICE >= "100"
Less than operator
The less than operator is $lt
. This operator will find records where the property's value is less than the provided conditional value.
Example
const items = await Item.find({ price: { $lt: 100 } });
The query which will be executed on the MultiValue database is:
select ITEM with PRICE < "100"
Less than or equal to operator
The less than or equal to operator is $lte
. This operator will find records where the property's value is less than or equal to the provided conditional value.
Example
const items = await Item.find({ price: { $lte: 100 } });
The query which will be executed on the MultiValue database is:
select ITEM with PRICE <= "100"