Skip to main content
Document commands provide CRUD operations for working with individual documents in collections.

doc insert

Insert a new document into a collection. Auto-generates an ID if not provided.
jasonisnthappy <DATABASE> doc insert <COLLECTION> <DOCUMENT>

Arguments

  • collection - Name of the collection (created automatically if it doesn’t exist)
  • document - JSON document to insert

Examples

jasonisnthappy mydb.db doc insert users '{"name":"Alice","age":30}'

Output

✓ Document inserted
  Collection: users
  ID: 1
If the collection doesn’t exist, it will be created automatically on first insert.

doc find

Find documents matching a query filter. Returns all matching documents.
jasonisnthappy <DATABASE> doc find <COLLECTION> [QUERY] [--limit N] [--skip N]

Arguments

  • collection - Name of the collection to query
  • query - 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

jasonisnthappy mydb.db doc find users

Query operators

The CLI supports all jasonisnthappy query operators:
OperatorDescriptionExample
$eqEqual to{"age":{"$eq":30}}
$neNot equal to{"status":{"$ne":"inactive"}}
$gtGreater than{"age":{"$gt":25}}
$gteGreater than or equal{"age":{"$gte":25}}
$ltLess than{"age":{"$lt":40}}
$lteLess than or equal{"age":{"$lte":40}}
$inIn array{"status":{"$in":["active","pending"]}}
$ninNot in array{"role":{"$nin":["guest","banned"]}}
$andLogical AND{"$and":[{"age":{"$gte":25}},{"city":"NYC"}]}
$orLogical OR{"$or":[{"age":{"$lt":18}},{"age":{"$gte":65}}]}
$notLogical NOT{"$not":{"status":"inactive"}}

Output

Found 2 documents:

Document ID: 1
{
  "name": "Alice",
  "age": 30,
  "email": "alice@example.com"
}

Document ID: 2
{
  "name": "Bob",
  "age": 28,
  "email": "bob@example.com"
}
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.
jasonisnthappy <DATABASE> doc find-one <COLLECTION> <QUERY>

Arguments

  • collection - Name of the collection
  • query - JSON query filter

Example

jasonisnthappy mydb.db doc find-one users '{"email":"alice@example.com"}'

Output

{
  "_id": 1,
  "name": "Alice",
  "age": 30,
  "email": "alice@example.com"
}

doc update

Update documents matching a query filter.
jasonisnthappy <DATABASE> doc update <COLLECTION> <QUERY> <UPDATE>

Arguments

  • collection - Name of the collection
  • query - JSON query filter (selects which documents to update)
  • update - JSON update operations

Update operators

OperatorDescriptionExample
$setSet field values{"$set":{"age":31}}
$unsetRemove fields{"$unset":{"temp_field":""}}
$incIncrement number{"$inc":{"views":1}}
$pushAdd to array{"$push":{"tags":"new"}}
$pullRemove from array{"$pull":{"tags":"old"}}

Examples

jasonisnthappy mydb.db doc update users \
  '{"name":"Alice"}' \
  '{"$set":{"age":31,"city":"Boston"}}'

Output

✓ Documents updated
  Collection: users
  Matched: 3
  Modified: 3
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.
jasonisnthappy <DATABASE> doc delete <COLLECTION> <QUERY>

Arguments

  • collection - Name of the collection
  • query - JSON query filter (selects which documents to delete)

Examples

jasonisnthappy mydb.db doc delete users '{"_id":1}'

Output

✓ Documents deleted
  Collection: users
  Deleted: 5
Deletes are permanent and cannot be undone. Use doc find to preview which documents will be deleted before running the delete command.

doc count

Count documents matching a query filter.
jasonisnthappy <DATABASE> doc count <COLLECTION> [QUERY]

Arguments

  • collection - Name of the collection
  • query - JSON query filter (default: {} counts all documents)

Examples

jasonisnthappy mydb.db doc count users

Output

Count: 1,234 documents

query run

Run an advanced query with filtering, sorting, and pagination.
jasonisnthappy <DATABASE> query run <COLLECTION> [OPTIONS]

Flags

  • --filter / -f - Query filter as JSON (default: {})
  • --sort / -s - Field to sort by
  • --order - Sort order: asc or desc (default: asc)
  • --limit / -l - Maximum number of results
  • --skip - Number of results to skip

Examples

jasonisnthappy mydb.db query run users --sort age --order asc

Output

[
  {"_id":5,"name":"Alice","age":25},
  {"_id":3,"name":"Bob","age":28},
  {"_id":1,"name":"Charlie","age":30}
]

query aggregate

Run an aggregation pipeline for complex data transformations.
jasonisnthappy <DATABASE> query aggregate <COLLECTION> <PIPELINE>

Arguments

  • collection - Name of the collection
  • pipeline - Aggregation pipeline as JSON array

Example

jasonisnthappy mydb.db query aggregate users '[
  {"$match": {"age": {"$gte": 25}}},
  {"$group": {
    "_id": "$city",
    "count": {"$sum": 1},
    "avg_age": {"$avg": "$age"}
  }},
  {"$sort": {"count": -1}}
]'

Output

[
  {"_id":"New York","count":45,"avg_age":32.5},
  {"_id":"Boston","count":23,"avg_age":29.8},
  {"_id":"Chicago","count":18,"avg_age":31.2}
]
Perform full-text search with TF-IDF scoring.
jasonisnthappy <DATABASE> query search <COLLECTION> <TEXT> [--limit N]

Arguments

  • collection - Name of the collection
  • text - Search text

Flags

  • --limit / -l - Maximum number of results

Example

jasonisnthappy mydb.db query search products "wireless headphones" --limit 5

Output

Search results for 'wireless headphones':

[1] Score: 0.87
{
  "_id": 42,
  "name": "Premium Wireless Headphones",
  "description": "Bluetooth wireless headphones with noise cancellation"
}

[2] Score: 0.65
{
  "_id": 108,
  "name": "Budget Wireless Earbuds",
  "description": "Affordable wireless earbuds for everyday use"
}
Full-text search requires indexed text fields. Results are ranked by relevance using TF-IDF scoring.

Collection commands

Manage collections and schemas

Interactive REPL

Work with documents interactively

Build docs developers (and LLMs) love