Queries
Queries give you powerful NoSQL database-like functionality for content fetching. Use the query
parameter to send a valid JSON query on Objects and Media endpoints.
Note
If accessing the endpoint via browser address bar, open and closed
curly braces will need to be encoded: %7B
and %7D
respectively. This
encoder tool may help.
Object attributes
Construct queries to search by the following Object attributes.
Parameter | Description |
---|---|
id | Object Id |
title | Object Title |
slug | Object Slug |
content | Object Content |
type | Object Type Slug |
status | Object Status |
locale | Object Locale |
created_at | Object Created at Date |
published_at | Object Published at Date |
modified_at | Object Modified at Date |
created_by | Object Created by user id |
modified_by | Object Modified by user id |
metadata.$key | Metadata value(s) |
Media attributes
Construct queries to search by the following Media attributes.
Parameter | Description |
---|---|
id | Media Id |
name | Media name |
original_name | Media original name |
size | Media size |
type | Media type |
created | Media created date |
folder | Media folder |
metadata | Media metadata (JSON) |
Selectors
Use the following selectors to build your queries.
Parameter | Description |
---|---|
$eq | Matches values that are equal to a specified value. Default key/value query. |
$gt | Matches values that are greater than a specified value. |
$gte | Matches values that are greater than or equal to a specified value. |
$lt | Matches values that are less than a specified value. |
$lte | Matches values that are less than or equal to a specified value. |
$in | Matches any of the values specified in an array. |
$all | Matches all of the values specified in an array. |
$ne | Matches all values that are not equal to a specified value. |
$nin | Matches none of the values specified in an array. |
Evaluation
Parameter | Description |
---|---|
$regex, $options | Search for string, use $options: "i" for case insensitive matches. |
Logic Operators
Parameter | Description |
---|---|
$and | Returns Objects that match all of the query conditions. |
$not | Returns Objects that do not match the query expression. |
$or | Returns Objects that match any of the specified conditions. |
$nor | Returns Objects that fail to match any of the specified conditions. |
Examples
Learn More
Go to the examples section in the docs to learn
more about Cosmic queries and available methods.
More query info
Want more information?
Cosmic queries follow MongoDB methods of comparison and logical operators. See
further documentation and more examples in the MongoDB
docs.