Querying Data
FlintDB queries are JSON objects. Each query targets a collection and can include filtering, sorting, grouping, and aggregation.
Basic Query Structure
Section titled “Basic Query Structure”{ "collection": "collectionName", "filter": { ... }, "sort": { "field": "asc" | "desc" }, "limit": 10, "select": ["field1", "field2"]}Filtering
Section titled “Filtering”Filter documents by field values:
{ "collection": "orders", "filter": { "status": "shipped", "total": { "$gt": 100 } }}Filter Operators
Section titled “Filter Operators”| Operator | Description |
|---|---|
$gt | Greater than |
$gte | Greater than or equal |
$lt | Less than |
$lte | Less than or equal |
$ne | Not equal |
$in | In array |
Sorting
Section titled “Sorting”Sort results by one or more fields:
{ "collection": "products", "sort": { "price": "desc" }}Grouping
Section titled “Grouping”Group documents and compute aggregates per group:
{ "collection": "sales", "groupBy": "region", "aggregate": { "totalRevenue": { "sum": "amount" }, "orderCount": { "count": true } }}Limiting Results
Section titled “Limiting Results”{ "collection": "logs", "sort": { "timestamp": "desc" }, "limit": 50}