ToollessToolless

update

Update command reference

Syntax

update.sh
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 JSON

Alias: u

Options

OptionDescriptionDefault
--path <path>Path to database directory./data
--manyUpdate all matching documents-
--upsertCreate document if not found-
--jsonOutput result as JSON-

Arguments

ArgumentDescription
<database>Database name
<collection>Collection name
<filter>Query filter (JSON)
<update>Update operations (JSON)

Examples

Update a single document:

update.sh
toollessdb update mydb users '{"name":"Alice"}' '{"$set":{"age":31}}'

Update all matching documents:

update.sh
toollessdb update mydb users '{"active":false}' '{"$set":{"status":"inactive"}}' --many

Upsert Option

Use --upsert to create the document if no matching document exists.

Update with upsert:

update.sh
toollessdb update mydb users '{"email":"new@example.com"}' '{"$set":{"name":"New User"}}' --upsert

Output result as JSON:

update.sh
toollessdb update mydb users '{"_id":"507f1f77bcf86cd799439011"}' '{"$set":{"status":"active"}}' --json

On this page