Query Selectors
When creating queries in the hyper cloud you need to build your query filter using a special syntax called a selector. The selector is a JSON structure that allows you to create logic patterns to inform the service how to appropriately return the correct documents.
Selector | Description | Example * |
$eq | Equals, match when property equals this value | { "title": { "$eq": "Ghostbusters"}} |
$ne | The property does not equal the value | { "title": {"$ne": "Groundhog Day"}} |
$lt | The property value is less than the value | { "year": {"$lt": "1990"}} |
$lte | The property value is less than or equal to the value | { "year": { "$lte": "1990"}} |
$gte | The property value is greater than or equal to the value | { "year": {"$gte": "2000"}} |
$gt | The property value is greater than | { "year": {"gt": "2000"}} |
$exists | Check whether the property exists | { "type": {"$exists": true}} |
$type | Check the properites type, valid values are "null", "boolean", "number", "string", "array", "object" | { "title": {"$type": "string"}} |
$in | The document property must exist in the list of values provided. | { "title": {"$in": ["Star Wars", "Star Trek"]}} |
$nin | The document property must not exist in the list of values provided. | { "title": {"$nin": ["Superman", "Spiderman"]}} |
$mod | The document property value modulus a divisor that equals a remainder. eg [Divisor, Remainer] | { "total": {"$mod": [2, 0]}} // even numbers |
$regex | The document property must be a string and the regex expression matches all documents that match the regex | { "title": {"$regex": "^Star" }} |
In the examples above, the JSON Document represents a "KEY" : "VALUE" Pair where the "title" string is a property on the JSON Document.
By default, every selector in the root branch of the selector object must be true, which results in an and operation. Sometimes you may want an or operation, in that case, you need to wrap your selectors in an $or property.
You can also use the $and selector if you have to combine both.
Need Help?
You can always reach out to our support team for any additional assistance on slack.
