update
Update command reference
Syntax
toollessdb update <database> <collection> <filter> <update>
--path <path> Path to database directory (default: ./data)
--many Update all matching documents
--upsert Create document if not found
--json Output result as JSONAlias: u
Options
| Option | Description | Default |
|---|---|---|
--path <path> | Path to database directory | ./data |
--many | Update all matching documents | - |
--upsert | Create document if not found | - |
--json | Output result as JSON | - |
Arguments
| Argument | Description |
|---|---|
<database> | Database name |
<collection> | Collection name |
<filter> | Query filter (JSON) |
<update> | Update operations (JSON) |
Examples
Update a single document:
toollessdb update mydb users '{"name":"Alice"}' '{"$set":{"age":31}}'Update all matching documents:
toollessdb update mydb users '{"active":false}' '{"$set":{"status":"inactive"}}' --manyUpsert Option
Use --upsert to create the document if no matching document exists.
Update with upsert:
toollessdb update mydb users '{"email":"new@example.com"}' '{"$set":{"name":"New User"}}' --upsertOutput result as JSON:
toollessdb update mydb users '{"_id":"507f1f77bcf86cd799439011"}' '{"$set":{"status":"active"}}' --json