Getting Started

Tutorial: Building with CleaveDB

The UPDATE Command

In addition to CHANGE, CleaveQL natively supports the UPDATE command. If you come from a relational SQL background, UPDATE offers immediate familiarity while operating directly on flexible JSON documents within CleaveDB buckets.

Direct document update

You can target a specific document by its bucket and ID:

CleaveQLExample · Update a user by ID
UPDATE users "jane" SET status = "active"

This updates the status property on Jane's document in place. Existing graph bonds, tenant namespaces, and untouched properties are fully preserved.

Updating multiple fields with UPDATE

Set multiple fields simultaneously with comma-separated assignments:

CleaveQLExample · Update multiple fields
UPDATE users "jane" SET status = "verified", plan = "pro", updated_at = 1712750400

All field updates are processed atomically through CleaveDB's Write-Ahead Log (WAL).

Conditional updates with WHERE

Use WHERE to update every document meeting specific criteria across a bucket:

CleaveQLExample · Conditional batch update
UPDATE orders WHERE status = "pending" SET status = "processing"

Every document satisfying the WHERE clause is updated in an atomic transaction.

Sub-queries inside UPDATE

Embed nested SCOOP queries directly within your UPDATE condition:

CleaveQLExample · Update using nested sub-query
UPDATE orders SET status = "flagged" WHERE customer_id IN (
  SCOOP users WHOSE status IS "banned" YIELD gid
)

The sub-query resolves the candidate user IDs, and the outer UPDATE modifies all corresponding order records seamlessly.