doc insert
Insert a new document into a collection. Auto-generates an ID if not provided.Arguments
collection- Name of the collection (created automatically if it doesn’t exist)document- JSON document to insert
Examples
Output
doc find
Find documents matching a query filter. Returns all matching documents.Arguments
collection- Name of the collection to queryquery- JSON query filter (default:{}returns all documents)
Flags
--limit/-l- Maximum number of documents to return--skip/-s- Number of documents to skip (for pagination)
Examples
Query operators
The CLI supports all jasonisnthappy query operators:| Operator | Description | Example |
|---|---|---|
$eq | Equal to | {"age":{"$eq":30}} |
$ne | Not equal to | {"status":{"$ne":"inactive"}} |
$gt | Greater than | {"age":{"$gt":25}} |
$gte | Greater than or equal | {"age":{"$gte":25}} |
$lt | Less than | {"age":{"$lt":40}} |
$lte | Less than or equal | {"age":{"$lte":40}} |
$in | In array | {"status":{"$in":["active","pending"]}} |
$nin | Not in array | {"role":{"$nin":["guest","banned"]}} |
$and | Logical AND | {"$and":[{"age":{"$gte":25}},{"city":"NYC"}]} |
$or | Logical OR | {"$or":[{"age":{"$lt":18}},{"age":{"$gte":65}}]} |
$not | Logical NOT | {"$not":{"status":"inactive"}} |
Output
- pretty
- json
The default query
{} matches all documents. Omit the query parameter to find all documents.doc find-one
Find a single document matching the query. Returns only the first match.Arguments
collection- Name of the collectionquery- JSON query filter
Example
Output
doc update
Update documents matching a query filter.Arguments
collection- Name of the collectionquery- JSON query filter (selects which documents to update)update- JSON update operations
Update operators
| Operator | Description | Example |
|---|---|---|
$set | Set field values | {"$set":{"age":31}} |
$unset | Remove fields | {"$unset":{"temp_field":""}} |
$inc | Increment number | {"$inc":{"views":1}} |
$push | Add to array | {"$push":{"tags":"new"}} |
$pull | Remove from array | {"$pull":{"tags":"old"}} |
Examples
Output
Updates affect all documents matching the query. Use
doc find first to preview which documents will be updated.doc delete
Delete documents matching a query filter.Arguments
collection- Name of the collectionquery- JSON query filter (selects which documents to delete)
Examples
Output
doc count
Count documents matching a query filter.Arguments
collection- Name of the collectionquery- JSON query filter (default:{}counts all documents)
Examples
Output
query run
Run an advanced query with filtering, sorting, and pagination.Flags
--filter/-f- Query filter as JSON (default:{})--sort/-s- Field to sort by--order- Sort order:ascordesc(default:asc)--limit/-l- Maximum number of results--skip- Number of results to skip
Examples
Output
query aggregate
Run an aggregation pipeline for complex data transformations.Arguments
collection- Name of the collectionpipeline- Aggregation pipeline as JSON array
Example
Output
query search
Perform full-text search with TF-IDF scoring.Arguments
collection- Name of the collectiontext- Search text
Flags
--limit/-l- Maximum number of results
Example
Output
Related commands
Collection commands
Manage collections and schemas
Interactive REPL
Work with documents interactively