--- # README.md # Fluree DB A semantic graph database with time travel, branching, and verifiable data — built on W3C standards. Fluree DB is a single binary that stores your data as an RDF knowledge graph, queryable with SPARQL or JSON-LD Query, with every commit immutably recorded so you can travel back to any prior state. It supports git-style branching and merging, signed and policy-gated transactions, SHACL validation, OWL/RDFS reasoning, and full-text and vector search — over local files, S3, or IPFS — without bolting on external services. ## What you get - **Semantic by default.** Your data is RDF. IRIs, JSON-LD `@context`, named graphs, and typed values are first-class. Queries are SPARQL 1.1 or the equivalent JSON-LD Query, both compiling to the same execution engine. - **Property graphs and statement-level metadata.** Attach properties to a *relationship*, not just a node — `role` and `since` on a `worksFor` edge, `source` and `confidence` on a claim — with RDF 1.2 / SPARQL 1.2 edge annotations. Labeled-property-graph edges, parallel relationships between the same two nodes, and RDF-star provenance all live on one surface, and plain triple queries are left undisturbed. See [Edge annotations](concepts/edge-annotations.md). - **Time travel.** Every transaction is a commit on an immutable chain. Query the state of the graph at any past moment with a single `t` parameter — no snapshots to restore, no separate audit log to consult. - **Branching and merging.** Create a branch off any commit, transact against it in isolation, then merge it back. Useful for staging changes, running what-if analyses, or maintaining environment-specific overlays. - **Verifiable data.** Transactions and commits can be signed (JWS / W3C Verifiable Credentials). The commit chain is content-addressed, so any tampering is detectable. Pair it with policy enforcement to prove *who* changed *what* and *when* they were allowed to. - **Policy-based access control.** Policies are written as graph data, evaluated per query and per transaction, and travel with the ledger — not bolted on at the API layer. - **Storage your way.** Local filesystem for development, S3 + DynamoDB for production, IPFS for content-addressed distribution. The same ledger format works across all of them. - **Search built in.** BM25 full-text indexing and HNSW vector search live alongside SPARQL — no separate search service to operate. - **Reasoning.** OWL/RDFS inference and Datalog rules run inside the query engine, so derived facts are queryable without a materialization step. - **Embeddable.** The same engine that powers the server runs as a Rust library, generic over storage and nameservice. Use it directly in your application or run it standalone over HTTP. ## Start here - **New to Fluree?** → [Getting started](getting-started/) - **Run the server** → [Quickstart: run the server](getting-started/quickstart-server.md) - **Create a ledger and write data** → [Quickstart: create a ledger](getting-started/quickstart-ledger.md) → [Quickstart: write data](getting-started/quickstart-write.md) - **Query data** → [Quickstart: query (JSON-LD + SPARQL)](getting-started/quickstart-query.md) - **End-to-end walkthrough** → [Tutorial: search, time travel, branching, policies](getting-started/tutorial-end-to-end.md) - **Coming from SQL?** → [Fluree for SQL developers](getting-started/fluree-for-sql-developers.md) - **Embedding in Rust?** → [Using Fluree as a Rust library](getting-started/rust-api.md) ## Explore the docs - [Concepts](concepts/) — ledgers, graph sources, IRIs, datatypes, edge annotations, time travel, policy, verifiable data, reasoning - [Guides (cookbooks)](guides/) — query patterns, search, time travel, branching, policies, SHACL, edge annotations — task-oriented recipes - [CLI reference](cli/) — every `fluree` command, flag by flag - [HTTP API](api/) — endpoints, headers, signed requests, error model - [Query](query/) — JSON-LD Query, SPARQL, output formats, CONSTRUCT, explain plans, reasoning - [Transactions](transactions/) — insert, upsert, update, conditional updates, signed transactions - [Security and policy](security/) — authentication, encryption, commit signing, policy model - [Indexing and search](indexing-and-search/) — background indexing, BM25, vector search, geospatial - [Graph sources and integrations](graph-sources/) — Iceberg/Parquet, R2RML, BM25 graph source - [Operations](operations/) — configuration, Docker, storage modes, telemetry, archive/restore - [Design](design/) — internals: query execution, storage traits, index format, nameservice - [Reference](reference/) — glossary, vocabulary, OWL/RDFS support, crate map - [Troubleshooting](troubleshooting/) — common errors, debugging queries, performance tracing - [Contributing](contributing/) — dev setup, tests, SPARQL compliance, releasing The full table of contents is in the sidebar. ## Building with AI and agents [Fluree for AI and agents](ai/) features for the AI use case — it ties together Agent JSON (token-efficient query output), the MCP server (Fluree as an agent tool), Fluree Memory, vector and full-text search as a RAG substrate, and reasoning. ## Fluree Memory [Fluree Memory](memory/) is persistent, searchable memory for AI coding assistants — built on Fluree DB and shipped in the same `fluree` binary. If you're here for the memory tooling, jump straight to the [Memory docs](memory/). --- # cli/README.md # Fluree CLI The `fluree` command-line interface provides a convenient way to manage ledgers, run queries, and perform transactions without running a server. ## Installation Build from source: ```bash cargo build --release -p fluree-db-cli ``` The binary will be at `target/release/fluree`. ## Quick Start ```bash # Initialize a project directory fluree init # Create a ledger fluree create myledger # Insert data fluree insert '@prefix ex: . ex:alice a ex:Person ; ex:name "Alice" .' # Query fluree query 'SELECT ?name WHERE { ?s ?name }' ``` ## Global Options | Option | Description | |--------|-------------| | `-v, --verbose` | Enable verbose output | | `-q, --quiet` | Suppress non-essential output | | `--no-color` | Disable colored output (also respects `NO_COLOR` env var) | | `--config ` | Path to config file | | `--memory-budget-mb ` | Memory budget in MB for bulk import (0 = auto: 60% of system RAM). Affects chunk size, concurrency, and run budget when creating a ledger with `--from`. Set this to cap memory use; auto-detected thread count shrinks to fit it. | | `--parallelism ` | Number of parallel parse threads for bulk import (0 = auto: most logical cores, capped to fit the memory budget; explicit values honored as-is, floored at 1). Used when creating a ledger with `--from`. | | `-h, --help` | Print help | | `-V, --version` | Print version | ## Commands ### Core Commands | Command | Description | |---------|-------------| | [`init`](init.md) | Initialize a new Fluree project directory | | [`create`](create.md) | Create a new ledger | | [`use`](use.md) | Set the active ledger | | [`list`](list.md) | List all ledgers | | [`info`](info.md) | Show detailed information about a ledger | | [`drop`](drop.md) | Drop (delete) a ledger | | [`graph`](graph.md) | Manage named graphs within a ledger (list, drop) | | [`insert`](insert.md) | Insert data into a ledger | | [`upsert`](upsert.md) | Upsert data (insert or update existing) | | [`update`](update.md) | Update with WHERE/DELETE/INSERT patterns | | [`query`](query.md) | Query a ledger | | [`history`](history.md) | Show change history for an entity | | [`export`](export.md) | Export ledger data | | [`log`](log.md) | Show commit log | | [`show`](show.md) | Show decoded commit contents (flakes with resolved IRIs) | | [`index`](index.md) | Build or update the binary index (incremental) | | [`reindex`](reindex.md) | Full reindex from commit history | ### Remote Sync | Command | Description | |---------|-------------| | [`remote`](remote.md) | Manage remote servers | | [`upstream`](upstream.md) | Manage upstream tracking configuration | | [`fetch`](fetch.md) | Fetch refs from a remote | | [`clone`](clone.md) | Clone a ledger from a remote (full commit download) | | [`pull`](pull.md) | Pull commits from upstream | | [`push`](push.md) | Push to upstream remote | | [`track`](track.md) | Track remote-only ledgers (no local data) | **Clone and pull** transfer commits and, by default, **binary index data** from the remote (pack protocol), so the local ledger is query-ready without a separate reindex. Use `--no-indexes` to skip index transfer and reduce download size; run `fluree reindex` afterward if you need the index. Large transfers may prompt for confirmation before streaming. ### Server Management | Command | Description | |---------|-------------| | [`server`](server.md) | Manage the Fluree HTTP server (run, start, stop, status, restart, logs) | Start a server directly from a project directory — it inherits the same `.fluree/` context (config, storage) as the CLI. See [`server`](server.md) for details. ### Implementers If you're building a custom server that must support the CLI end-to-end (for example, integrating into another app), see: - [`server-integration`](server-integration.md) - endpoints and auth contract required by the CLI ### Authentication | Command | Description | |---------|-------------| | [`token`](token.md) | Create, inspect, and manage JWS tokens | | [`auth`](auth.md) | Manage bearer tokens stored on remotes (login/logout/status) | ### Configuration | Command | Description | |---------|-------------| | [`config`](config.md) | Manage configuration | | [`prefix`](prefix.md) | Manage IRI prefix mappings | | [`completions`](completions.md) | Generate shell completions | ### Developer Memory | Command | Description | |---------|-------------| | [`memory`](memory.md) | Store and recall facts, decisions, constraints, preferences, and artifact references | | [`mcp`](mcp.md) | MCP server for IDE agent integration | For background, IDE setup, team workflows, and the `mem:` schema, see the [Memory section](../memory/README.md) of the docs. ## Project Structure When you run `fluree init`, a `.fluree/` directory is created with: ``` .fluree/ ├── active # Currently active ledger name ├── config.toml # Configuration settings ├── prefixes.json # IRI prefix mappings └── storage/ # Ledger data storage ``` ## Input Resolution Commands that accept data input (`insert`, `upsert`, `update`, `query`) use flexible argument resolution: | Arguments | Behavior | |-----------|----------| | (none) | Active ledger; provide input via `-e`, `-f`, or stdin | | `` | Auto-detected: if it looks like a query/data, uses it inline; if it's an existing file, reads from it; otherwise treats it as a ledger name | | ` ` | Specified ledger + inline input | Input is resolved in this priority order: `-e` flag > positional inline > `-f` flag > positional file > stdin. ## Data Format Detection The CLI auto-detects data format based on content: - Lines starting with `@prefix` or `@base` → Turtle - Content starting with `{` or `[` → JSON-LD - Files with `.ttl` extension → Turtle - Files with `.json` or `.jsonld` extension → JSON-LD You can override with `--format turtle` or `--format jsonld`. --- # cli/init.md # fluree init Initialize a new Fluree project directory. ## Usage ```bash fluree init [OPTIONS] ``` ## Options | Option | Description | | ---------- | --------------------------------------------------------------------------------- | | `--global` | Create global config and data directories instead of a local `.fluree/` directory | ## Description Creates a `.fluree/` directory in the current working directory (or global directories with `--global`). This directory stores: - `active` - The currently active ledger name - `config.toml` - Configuration settings - `prefixes.json` - IRI prefix mappings for compact IRIs - `storage/` - Ledger data Running `init` is idempotent - it won't overwrite existing configuration. ## Examples ```bash # Initialize in current directory fluree init # Initialize global config fluree init --global ``` ## Global Directory With `--global`, the directories are determined by: 1. `$FLUREE_HOME` environment variable (if set) — both config and data go in this single directory. 2. Platform directories (when `$FLUREE_HOME` is not set): | Content | Linux | macOS | Windows | | -------------------------------------------- | ---------------------------------------------------------- | -------------------------------------- | ----------------------- | | Config (`config.toml`) | `$XDG_CONFIG_HOME/fluree` (default: `~/.config/fluree`) | `~/Library/Application Support/fluree` | `%LOCALAPPDATA%\fluree` | | Data (`storage/`, `active`, `prefixes.json`) | `$XDG_DATA_HOME/fluree` (default: `~/.local/share/fluree`) | `~/Library/Application Support/fluree` | `%LOCALAPPDATA%\fluree` | On macOS and Windows both resolve to the same directory (unified); on Linux config and data are separated per XDG conventions. The generated `config.toml` will contain an absolute `storage_path` pointing to the data directory when the directories are split. ## See Also - [create](create.md) - Create a new ledger after initialization --- # cli/create.md # fluree create Create a new ledger. ## Usage ```bash fluree create [OPTIONS] ``` ## Arguments | Argument | Description | |----------|-------------| | `` | Name for the new ledger | ## Options | Option | Description | |--------|-------------| | `--from ` | Import data from a file (Turtle, N-Triples, N-Quads, TriG, or JSON-LD), optionally `.gz`- or `.zst`-compressed. N-Triples (`.nt`) parses as Turtle; N-Quads (`.nq`) converts to TriG (named graphs supported). A `.flpack` archive (see [export](export.md)) is restored wholesale instead — full ledger including its prebuilt index. | | `--remote ` | Create on a remote server instead of locally. With no `--from`, creates an empty ledger. With `--from .flpack`, streams the archive to the server's import endpoint to restore the ledger remotely. Other `--from` formats are not supported remotely — export to `.flpack` first, or create locally then [publish](publish.md). | | `--memory [PATH]` | Import memory history from a git-tracked `.fluree-memory/` directory. Defaults to the current repo if no path is given. Mutually exclusive with `--from`. | | `--no-user` | Exclude user-scoped memories (`.local/user.ttl`) from `--memory` import | | `--chunk-size-mb ` | Chunk size in MB for splitting large Turtle files (0 = derive from memory budget). Only used when `--from` points to a `.ttl` or `.nt` file. | | `--leaflet-rows ` | Rows per leaflet in the binary index (default: 25000). Larger values produce fewer, bigger leaflets — less I/O per scan, more memory per read. | | `--leaflets-per-leaf ` | Leaflets per leaf file (default: 10). Larger values produce fewer leaf files — shallower tree, bigger reads. | **Global flags** that affect bulk import when using `--from` (see [CLI README](README.md#global-options)): - `--memory-budget-mb ` — Memory budget in MB (0 = auto: 60% of system RAM). Drives chunk size, concurrency, and indexer run budget. Set this to cap how much memory the import uses; auto-detected thread count shrinks to fit it. - `--parallelism ` — Number of parallel parse threads (0 = auto: most logical cores, capped to fit the memory budget; explicit values honored as-is, floored at 1). ## Description Creates a new empty ledger with the given name and sets it as the active ledger. The ledger is stored in `.fluree/storage/`. Use `--from` to create a ledger pre-populated with data from a Turtle, N-Triples, N-Quads, TriG, or JSON-LD file (or a directory of same-format files). Any input may be gzip- or zstd-compressed and is decoded transparently (`data.ttl.gz`, `dump.nq.zst`, mixed directories — the underlying RDF extension classifies the file). N-Triples (`.nt`) is a strict subset of Turtle and is parsed by the same parser. N-Quads (`.nq`) and TriG (`.trig`) support named graphs — queryable after import via the `#` fragment. For large Turtle/N-Triples files (including `.ttl.gz`/`.nt.gz`), the CLI splits work into chunks and runs parallel parse threads — though compressed inputs decode single-threaded; TriG/N-Quads/JSON-LD use a serial path. Tune with `--memory-budget-mb` and `--parallelism` if needed. **Directory imports (`.ttl`/`.nt`)** are *rechunked by bytes* rather than one-chunk-per-file: large files are sub-split at statement boundaries and many small files are coalesced into `~chunk_size` work items. This keeps the import fully parallel and bounds the number of commits and sorted index runs regardless of how the data is packaged — so a directory of one big file, or of hundreds of tiny shards, both import at full speed. Coalescing engages automatically once a directory holds more than 64 sub-`chunk_size` files; a file containing a labeled blank node (`_:`) or an `@base` directive is never coalesced (it would change RDF document scope) and is imported as its own chunk. Set `FLUREE_IMPORT_COALESCE_THRESHOLD=` to change the gate (`0` disables coalescing — every file becomes its own commit, the legacy behavior). Directories containing any `.trig`/`.nq`/`.jsonld` continue to use the per-file serial path. Use `--memory` to import your project's developer memory history into a time-travel-capable Fluree ledger. Each git commit that touched `.fluree-memory/repo.ttl` (and `.local/user.ttl` unless `--no-user` is set) becomes a Fluree transaction. The git commit message, SHA, and author date are stored as transaction metadata, so you can correlate Fluree `t` values with git history. ### Restoring from a `.flpack` archive When `--from` points at a `.flpack` file (produced by `fluree export --format ledger`), the ledger is restored *wholesale* rather than bulk-imported: every commit, transaction blob, and prebuilt index artifact is streamed straight into storage and the heads are set from the archive — the restored ledger is byte-for-byte identical and immediately queryable, under whatever name you choose. Add `--remote ` to restore onto a server instead of locally; the archive streams to the server's import endpoint, so no local staging instance is needed. This makes `.flpack` the universal way to move any data onto a server — build a ledger locally in any format, export it, then import it remotely. See [pack archive & restore](../operations/pack-archive-restore.md) for the full workflow. If the remote is size-capped (e.g. an app behind a payload-limited gateway) and advertises it in discovery, the CLI automatically switches to a negotiated upload: it uploads the archive out-of-band to object storage and the server restores from it asynchronously. No extra flags — the path is chosen from the server's capabilities and the archive size. ## Examples ```bash # Create an empty ledger fluree create mydb # Create with initial data fluree create mydb --from seed-data.ttl # Create from JSON-LD fluree create mydb --from initial.jsonld # Create with explicit memory and parallelism for a large Turtle file fluree create mydb --from large.ttl --memory-budget-mb 4096 --parallelism 8 # Restore a .flpack archive into a new local ledger (any name) fluree create restored-db --from mydb.flpack # Restore a .flpack archive onto a remote server fluree create restored-db --remote origin --from mydb.flpack # Import memory history from the current repo fluree create memories --memory # Import memory history from another repo, excluding user memories fluree create memories --memory /path/to/other/repo --no-user ``` ## Output ``` Created ledger 'mydb' Set 'mydb' as active ledger ``` With `--from`: ``` Created ledger 'mydb' Committed t=1 (42 flakes) Set 'mydb' as active ledger ``` With `--memory`: ``` Created ledger 'memories' with 42 commits (t=1..43) Earliest: bf803255 — initial memory store Latest: 9865e5cd — prevent overrides of fluree txn-meta Query with time travel: fluree query memories 'SELECT ?id ?content WHERE { ?id a mem:Fact ; mem:content ?content } LIMIT 5' fluree query memories --at-t 2 'SELECT ...' # state at first commit ``` ## See Also - [list](list.md) - List all ledgers - [use](use.md) - Switch active ledger - [drop](drop.md) - Delete a ledger --- # cli/use.md # fluree use Set the active ledger. ## Usage ```bash fluree use ``` ## Arguments | Argument | Description | |----------|-------------| | `` | Ledger name to set as active | ## Description Sets the specified ledger as the active ledger. Subsequent commands that don't specify a ledger will use this one. ## Examples ```bash # Switch to a different ledger fluree use production # Verify with info fluree info ``` ## Output ``` Active ledger set to 'production' ``` ## Errors If the ledger doesn't exist: ``` error: ledger 'nonexistent' not found ``` ## See Also - [list](list.md) - List all ledgers - [create](create.md) - Create a new ledger --- # cli/list.md # fluree list List all ledgers and graph sources. ## Usage ```bash fluree list ``` ## Description Lists all ledgers and graph sources (Iceberg, R2RML, BM25, Vector, etc.) in the current Fluree directory. The active ledger is marked with an asterisk (`*`). When graph sources are present, a TYPE column is shown to distinguish ledgers from graph sources. ## Examples ```bash fluree list ``` ## Output When only ledgers exist: ``` LEDGER BRANCH T * mydb main 5 production main 12 ``` When graph sources are also present: ``` NAME BRANCH TYPE T * mydb main Ledger 5 production main Ledger 12 warehouse-orders main Iceberg - my-search main BM25 5 ``` If nothing exists: ``` No ledgers found. Run 'fluree create ' to create one. ``` ## See Also - [create](create.md) - Create a new ledger - [iceberg](iceberg.md) - Map Iceberg tables as graph sources - [info](info.md) - Show detailed ledger or graph source information - [use](use.md) - Switch active ledger --- # cli/info.md # fluree info Show detailed information about a ledger or graph source. ## Usage ```bash fluree info [NAME] [--remote ] [--graph ] ``` ## Arguments | Argument | Description | |----------|-------------| | `[NAME]` | Ledger or graph source name (defaults to active ledger) | ## Options | Option | Description | |--------|-------------| | `--remote ` | Query a remote server (e.g., `origin`) instead of the local installation. | | `--graph ` | Scope the `stats` block to a single named graph within the ledger. Accepts a well-known name (`default`, `txn-meta`) or a graph IRI. Not applicable to graph sources. | ## Description Displays detailed information about a ledger or graph source. The command first checks for a matching ledger; if none is found, it checks for a graph source with the same name. For ledgers, displays: - Ledger ID, branch, and type - Current transaction number (t) - Commit and index details For graph sources (Iceberg, R2RML, BM25, etc.), displays: - Name, branch, and type - Graph source ID - Index status - Dependencies - Configuration (catalog URI, table, mapping, etc.) ## Examples ```bash # Info for active ledger fluree info # Info for specific ledger fluree info production # Info for a graph source fluree info warehouse-orders # Query a remote server fluree info production --remote origin # Scope stats to the default graph fluree info mydb --graph default # Scope stats to the transaction-metadata graph fluree info mydb --graph txn-meta # Scope stats to a specific named graph by IRI fluree info mydb --graph https://example.org/graphs/inventory ``` When `--graph` is set, the command prints the full `ledger-info` JSON response with the `stats` block scoped to the selected graph (properties, classes, flakes, size). ## Output Ledger: ``` Ledger: mydb Branch: main Type: Ledger Ledger ID: mydb:main Commit t: 5 Commit ID: bafybeig... Index t: 5 Index ID: bafybeig... ``` Graph source (Iceberg): ``` Name: warehouse-orders Branch: main Type: Iceberg ID: warehouse-orders:main Retracted: false Index t: 0 Index ID: (none) Configuration: { "catalog": { "type": "rest", "uri": "https://polaris.example.com/api/catalog" }, "table": "sales.orders", ... } ``` ## See Also - [list](list.md) - List all ledgers and graph sources - [iceberg](iceberg.md) - Map Iceberg tables as graph sources - [log](log.md) - Show commit history --- # cli/branch.md # fluree branch Manage branches for a ledger. ## Subcommands ### fluree branch create Create a new branch. **Usage:** ```bash fluree branch create [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `` | Name for the new branch (e.g., "dev", "feature-x") | **Options:** | Option | Description | |--------|-------------| | `--ledger ` | Ledger name (defaults to active ledger) | | `--from ` | Source branch to create from (defaults to "main") | | `--at ` | Commit to branch at (defaults to source branch HEAD). Accepts `t:N` for a transaction number or a hex digest / full CID. | | `--remote ` | Execute against a remote server | **Description:** Creates a new branch for a ledger. By default the branch starts at the source branch's current HEAD, and is fully isolated — subsequent transactions on either branch are invisible to the other. Pass `--at` to branch from a historical commit on the source branch instead of its HEAD. The commit must be reachable from the source HEAD; the new branch starts with no index and replays from genesis on first query. `t:N` and hex-prefix resolution require the source branch to be indexed (full CIDs work unconditionally). Branches can be nested: you can create a branch from any existing branch, not just "main". **Examples:** ```bash # Create a branch from main (default) fluree branch create dev # Create a branch for a specific ledger fluree branch create dev --ledger mydb # Create a branch from another branch fluree branch create feature-x --from dev # Branch at a historical point on main (transaction number) fluree branch create rewind --at t:5 # Branch at a historical commit by hex-digest prefix fluree branch create rewind --at 3dd028a7 # Create a branch on a remote server fluree branch create staging --ledger mydb --remote origin ``` **Output:** ``` Created branch 'dev' from 'main' at t=5 Ledger ID: mydb:dev ``` ### fluree branch list List all branches for a ledger. **Usage:** ```bash fluree branch list [LEDGER] [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `[LEDGER]` | Ledger name (defaults to active ledger) | **Options:** | Option | Description | |--------|-------------| | `--remote ` | List branches on a remote server | **Examples:** ```bash # List branches for the active ledger fluree branch list # List branches for a specific ledger fluree branch list mydb # List branches on a remote server fluree branch list mydb --remote origin ``` **Output:** ``` BRANCH T SOURCE main 5 - dev 7 main feature-x 8 dev ``` ### fluree branch drop Drop a branch from a ledger. **Usage:** ```bash fluree branch drop [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `` | Branch name to drop (e.g., "dev", "feature-x") | **Options:** | Option | Description | |--------|-------------| | `--ledger ` | Ledger name (defaults to active ledger) | | `--remote ` | Execute against a remote server | **Description:** Drops a branch from a ledger. The `main` branch cannot be dropped. - **Leaf branches** (no children) are fully deleted — storage artifacts are removed and the NsRecord is purged. - **Branches with children** are retracted (hidden from listings, reject new transactions) but storage is preserved so that child branches continue to work. When the last child is eventually dropped, the retracted parent is automatically cascade-purged. **Examples:** ```bash # Drop a branch fluree branch drop dev # Drop a branch for a specific ledger fluree branch drop dev --ledger mydb # Drop a branch on a remote server fluree branch drop staging --ledger mydb --remote origin ``` **Output (leaf branch):** ``` Dropped branch 'dev'. Artifacts deleted: 5 ``` **Output (branch with children):** ``` Branch 'dev' retracted (has children, storage preserved). ``` **Output (cascade):** ``` Dropped branch 'feature'. Artifacts deleted: 3 Cascaded drops: mydb:dev ``` ### fluree branch rebase Rebase a branch onto its source branch's current HEAD. **Usage:** ```bash fluree branch rebase [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `` | Branch name to rebase (e.g., "dev", "feature-x") | **Options:** | Option | Description | |--------|-------------| | `--ledger ` | Ledger name (defaults to active ledger) | | `--strategy ` | Conflict resolution strategy (default: "take-both"). Options: `take-both`, `abort`, `take-source`, `take-branch`, `skip` | | `--remote ` | Execute against a remote server | **Description:** Replays a branch's unique commits on top of the source branch's current HEAD. This brings the branch up to date with upstream changes. The `main` branch cannot be rebased. If the branch has no unique commits, a fast-forward rebase is performed — the branch point is simply updated to the source's current HEAD. Conflicts occur when both the branch and source have modified the same (subject, predicate, graph) tuples. See [conflict strategies](../concepts/ledgers-and-nameservice.md#rebasing-a-branch) for details. **Examples:** ```bash # Rebase with default strategy fluree branch rebase dev # Rebase with abort-on-conflict strategy fluree branch rebase dev --strategy abort # Rebase for a specific ledger fluree branch rebase feature-x --ledger mydb --strategy take-source # Rebase on a remote server fluree branch rebase dev --ledger mydb --remote origin ``` **Output (fast-forward):** ``` Fast-forward rebase of 'dev' to t=5. ``` **Output (with replay):** ``` Rebased 'dev': 3 commits replayed, 0 skipped, 1 conflicts, 0 failures. New branch point: t=8 ``` ### fluree branch diff Show a read-only merge preview between two branches. **Usage:** ```bash fluree branch diff [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `` | Source branch name to preview merging from (e.g., "dev", "feature-x") | **Options:** | Option | Description | |--------|-------------| | `--target ` | Target branch to preview merging into (defaults to source's parent branch) | | `--max-commits ` | Cap on per-side commit summaries shown (default: 50; pass 0 for unbounded in local mode) | | `--max-conflict-keys ` | Cap on conflict keys shown (default: 50; pass 0 for unbounded in local mode) | | `--no-conflicts` | Skip conflict computation for a cheaper preview | | `--conflict-details` | Include source/target flake values for returned conflict keys | | `--strategy ` | Strategy used for conflict detail labels (default: `take-both`). Options: `take-both`, `abort`, `take-source`, `take-branch` | | `--json` | Emit the raw JSON preview | | `--ledger ` | Ledger name (defaults to active ledger) | | `--remote ` | Execute against a remote server | **Description:** `branch diff` reports ahead/behind commits, fast-forward eligibility, and conflicting `(subject, predicate, graph)` keys without mutating state. With `--conflict-details`, the preview also shows the source and target values for the returned conflict keys and annotates what the selected strategy would do. **Examples:** ```bash # Preview merging dev into its parent fluree branch diff dev # Preview a specific target fluree branch diff dev --target main # Show value details and source-winning labels fluree branch diff dev --target main --conflict-details --strategy take-source # Emit raw JSON for UI tooling fluree branch diff dev --conflict-details --json ``` ### fluree branch merge Merge a source branch into a target branch. **Usage:** ```bash fluree branch merge [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `` | Source branch name to merge from (e.g., "dev", "feature-x") | **Options:** | Option | Description | |--------|-------------| | `--ledger ` | Ledger name (defaults to active ledger) | | `--target ` | Target branch to merge into (defaults to source's parent branch) | | `--strategy ` | Conflict resolution strategy (default: `take-both`). Options: `take-both`, `abort`, `take-source`, `take-branch`. | | `--remote ` | Execute against a remote server | **Description:** Merges a source branch into a target branch. When the target hasn't advanced since the source branched, this is a fast-forward; otherwise `--strategy` controls how conflicting edits are resolved (mirroring `branch rebase`). When `--target` is omitted, the merge target is inferred from the source branch's parent (the branch it was created from). After a successful merge, the source branch remains intact and can continue to receive new transactions and be merged again. Only the new commits since the last merge (or branch creation) are copied. **Examples:** ```bash # Merge dev into main (inferred from branch point) fluree branch merge dev # Merge feature-x into dev (explicit target) fluree branch merge feature-x --target dev # Merge for a specific ledger fluree branch merge dev --ledger mydb # Merge with source-winning conflict resolution fluree branch merge dev --target main --strategy take-source # Merge on a remote server fluree branch merge dev --ledger mydb --remote origin ``` **Output:** ``` Merged 'dev' into 'main' (fast-forward to t=8, 3 commits copied). ``` **Output (non-fast-forward):** ``` Merged 'dev' into 'main' (t=9, 3 commits copied, 1 conflicts). ``` ## See Also - [create](create.md) - Create a new ledger - [list](list.md) - List all ledgers - [info](info.md) - Show ledger details - [use](use.md) - Switch active ledger --- # cli/cluster.md # fluree cluster Bootstrap and manage a Raft cluster (replicated transaction servers). Wraps the Fluree server's private `/cluster/*` admin endpoints over HTTP. Run this from your operator workstation against each node's `--raft-listen-addr` (the VPC-internal admin port — not the client-facing port). The admin endpoints carry no built-in authentication; the CLI assumes reachability over a private network or SSH tunnel. For the full deployment recipe and architectural context, see [Raft clusters (replicated writes)](../operations/raft-clusters.md). ## Subcommands ### fluree cluster init Bootstrap a fresh single-node cluster on the seed node. Run **once**, against one node. That node becomes a single-voter cluster and auto-elects itself leader on the next election tick. Subsequent peers are added with `cluster add` and `cluster promote`. **Usage:** ```bash fluree cluster init [OPTIONS] ``` **Options:** | Option | Description | |-------------------------|-----------------------------------------------------------------------------| | `--addr ` | Admin URL of the seed node (e.g. `http://node-1-private:9090`). | | `--node-id ` | This node's id. Must be unique in the cluster and stable across restarts. | | `--raft-url ` | This node's inter-node Raft RPC URL (e.g. `http://node-1-private:9090/raft`). | | `--client-url ` | This node's client-facing URL — used by peers when forwarding writes (e.g. `http://node-1:8080`). | **Example:** ```bash fluree cluster init \ --addr http://node-1-private:9090 \ --node-id 1 \ --raft-url http://node-1-private:9090/raft \ --client-url http://node-1:8080 ``` Returns immediately on success. Fails with `409 Conflict` if the cluster has already been initialized. ### fluree cluster add Add a non-voting peer (learner) to an existing cluster. The new node replicates the log from the leader; once caught up it can be promoted to a voter with `cluster promote`. Issue against the current **leader**. **Usage:** ```bash fluree cluster add [OPTIONS] ``` **Options:** | Option | Description | |-------------------------|-----------------------------------------------------------------------------| | `--leader ` | Admin URL of the cluster leader. | | `--node-id ` | Id for the new peer. | | `--raft-url ` | New peer's inter-node Raft RPC URL. | | `--client-url ` | New peer's client-facing URL. | | `--blocking ` | Wait for the learner to catch up before returning. Default: `true`. | **Example:** ```bash fluree cluster add \ --leader http://node-1-private:9090 \ --node-id 2 \ --raft-url http://node-2-private:9090/raft \ --client-url http://node-2:8080 ``` `--blocking true` (default) is the right choice for orchestration scripts that immediately follow up with `cluster promote` — it removes the race between replication and the promote call. ### fluree cluster promote Change the cluster's voting membership. Promotes learners to voters or demotes / removes existing voters. Issue against the **leader**. **Usage:** ```bash fluree cluster promote [OPTIONS] ``` **Options:** | Option | Description | |-------------------------|------------------------------------------------------------------------------| | `--leader ` | Admin URL of the cluster leader. | | `--members ,...` | New voter set, comma-separated (e.g. `1,2,3`). | | `--retain` | Keep voters dropped from `--members` as learners. Default: removed entirely. | **Examples:** ```bash # Promote learners 2 and 3 into the voting set. fluree cluster promote \ --leader http://node-1-private:9090 \ --members 1,2,3 # Drain node 3 — drop it from the voter set but keep it replicating # as a learner so reads stay current while you debug. fluree cluster promote \ --leader http://node-1-private:9090 \ --members 1,2 \ --retain ``` ### fluree cluster status Snapshot cluster state (current leader, term, voters, learners, last-applied log index). Any node's admin URL works — followers serve their last-known view, which is good enough for health checks and operator scripts. **Usage:** ```bash fluree cluster status --addr ``` **Example:** ```bash fluree cluster status --addr http://node-1-private:9090 ``` Output: ``` Cluster status leader: 1 term: 4 last_applied: 1283 voters: 1, 2, 3 learners: (none) ``` ## See also - [Raft clusters (replicated writes)](../operations/raft-clusters.md) — deployment recipe, architecture, security notes. --- # cli/drop.md # fluree drop Hard-drop an entire ledger (every branch under the name) or a graph source. ## Usage ```bash fluree drop --force ``` ## Arguments | Argument | Description | |----------|-------------| | `` | Ledger name (bare, e.g. `mydb`) or graph source name. Branch-qualified ledger ids (including `mydb:main`) are rejected — use `fluree branch drop --ledger mydb` to drop a single branch. | ## Options | Option | Description | |--------|-------------| | `--force` | Required flag to confirm deletion | ## Description Hard-drops a **whole ledger** — every branch under the name, including any retracted-but-not-purged branches, plus the cross-branch `@shared/dicts/` namespace. Branches are dropped leaf-first so partial failure leaves orphan parents rather than dangling children. Equivalent to `POST /drop` with `"hard": true`. Deleted artifacts are irreversible. The command first tries to drop the name as a ledger. If no nameservice record exists for the name, it tries to drop it as a graph source. This means `fluree drop` works uniformly for both ledgers and graph sources like Iceberg mappings. The `--force` flag is required to prevent accidental deletion. There is no CLI soft-drop flag; use the HTTP or Rust API if you need to retract a ledger while preserving artifacts. To remove a single branch (not the whole ledger), use `fluree branch drop`. Graph source cleanup is implementation-specific. The command retracts the graph source record and performs any available hard-drop cleanup for that graph source type; warnings are printed when cleanup is partial. ## Examples ```bash # Drop the whole "oldledger" ledger (all branches + @shared/dicts/) fluree drop oldledger --force # Drop a graph source (Iceberg mapping) fluree drop warehouse-orders --force ``` ## Output Ledger: ``` Dropped ledger 'oldledger' ``` Ledger with artifact cleanup: ``` Dropped ledger 'oldledger' (deleted 73 artifacts across 3 branches) ``` Graph source: ``` Dropped graph source 'warehouse-orders:main' ``` ## Errors Without `--force`: ``` error: use --force to confirm deletion of 'oldledger' ``` Branch-qualified input with a non-default suffix: ``` error: drop_ledger drops the whole ledger and does not accept a non-default branch suffix 'dev'. Use drop_branch("mydb", "dev") to drop a single branch, or pass "mydb" to drop the whole ledger. ``` ## Dropping a single named graph To drop just one **named graph** inside a ledger (without removing the ledger, the branch, or any other graph), use `fluree graph drop`: ```bash # Drop one named graph (active ledger, default branch) fluree graph drop urn:example:org/payroll # Drop on a specific ledger / branch fluree graph drop urn:example:org/payroll --ledger mydb fluree graph drop http://example.org/graphs/scratch --ledger mydb:feature-x # Drop via a tracked remote server fluree graph drop urn:example:org/payroll --ledger mydb --remote origin ``` Unlike `fluree drop`, `fluree graph drop` is **transactional and history- preserving**: it produces a normal commit at `t = current + 1` whose flakes retract every triple currently asserted in the graph, leaves the graph IRI registered (so subsequent inserts land in the same graph slot), and lets queries `as-of` an earlier `t` still see the dropped data. The graph IRI must be an absolute IRI (e.g. `urn:...`, `http://...`). The default graph and the system graphs (`urn:fluree:{ledger_id}#txn-meta` and `urn:fluree:{ledger_id}#config`) cannot be dropped. To see what graphs exist on a ledger, use `fluree graph list` (or look at the `named-graphs` section of `fluree info `). ## See Also - [create](create.md) - Create a new ledger - [iceberg](iceberg.md) - Map Iceberg tables as graph sources - [list](list.md) - List all ledgers and graph sources --- # cli/graph.md # fluree graph Manage **named graphs** within a single branch of a ledger. Named graphs are created implicitly: the first time you transact a triple under a new graph IRI (via TriG `GRAPH { ... }`, JSON-LD `@graph` with an `@id`, or SPARQL `INSERT DATA { GRAPH { ... } }`), the graph is registered and assigned a deterministic `g_id`. There is no separate "create graph" command — `fluree graph` only exposes the operations that don't fall out of `insert` / `upsert` / `update` for free. ## Subcommands ### fluree graph list List the user-defined named graphs registered on a branch. **Usage:** ```bash fluree graph list [OPTIONS] ``` **Options:** | Option | Description | |--------|-------------| | `--ledger ` | Ledger identifier (e.g. `mydb` or `mydb:feature-x`). Defaults to the active ledger. | | `--remote ` | List graphs on a remote server by remote name (e.g. `origin`). | | `--json` | Emit the filtered `named-graphs` JSON array instead of a table. | | `--include-system` | Include the default graph and the system `txn-meta` / `config` graphs. Off by default. | **Description:** Reads the `named-graphs` section of the standard `info` payload for the targeted branch — no new endpoint is required. By default, the output is restricted to user-defined graphs (`g_id >= 3`); pass `--include-system` to also surface the default graph (`g_id 0`), `txn-meta` (`g_id 1`), and `config` (`g_id 2`). Each row reports the graph IRI, kind (`user`, `default`, `system:txn-meta`, `system:config`), `g_id`, current flake count, and on-disk size. **Auto-routing:** like other read commands, `fluree graph list` auto-routes through a running local `fluree server` if one is up, or through the tracked remote when the active ledger has a `track` config. Pass `--direct` to bypass auto-routing and read from the local store, or `--remote ` to force a specific remote. **Examples:** ```bash # Active ledger, user graphs only fluree graph list # Specific ledger / branch fluree graph list --ledger mydb:feature-x # Remote fluree graph list --ledger mydb --remote origin # JSON output including system graphs fluree graph list --ledger mydb --include-system --json ``` ### fluree graph drop Drop a single named graph from one branch by transactionally retracting every triple currently asserted in it. **Usage:** ```bash fluree graph drop [OPTIONS] ``` **Arguments:** | Argument | Description | |----------|-------------| | `` | Full absolute IRI of the named graph to drop (e.g. `urn:example:org/payroll`). | **Options:** | Option | Description | |--------|-------------| | `--ledger ` | Ledger identifier. Defaults to the active ledger. | | `--remote ` | Execute against a remote server by remote name. | **Description:** `fluree graph drop` is **transactional and history-preserving**: - The drop produces one new commit at `t = current + 1` whose flakes are retractions of every triple currently asserted under the target graph IRI. - A query `as-of` an earlier `t` (e.g. via `--at t:`, `--at-time`, or a dataset `TimeSpec`) still sees the graph populated. - The graph IRI keeps its `g_id`; a subsequent insert into the same IRI lands in the same logical graph rather than a new slot. - Drops are per-branch — sibling branches that share the same graph IRI are not touched. - Idempotent: re-running the drop on an already-empty graph reports `committed: false`, `retracted: 0` and produces no new commit. The following are rejected with a clear error (no commit is produced): - The **default graph** — refuses an empty IRI, since the default graph cannot be dropped. - The **system graphs** — `urn:fluree:{ledger_id}#txn-meta` and `urn:fluree:{ledger_id}#config`. - **Relative references** — `` must be an absolute IRI with a valid `:` head (e.g. `urn:...`, `http://...`). - **Whitespace / control characters / RFC 3987-excluded characters** — leading/trailing whitespace is rejected, not silently trimmed. - **Unknown graph IRIs** — return a 404-shaped "not registered" error; the registry is never silently extended by a drop. **Examples:** ```bash # Drop on the active ledger fluree graph drop urn:example:org/payroll # Specific ledger or branch fluree graph drop urn:example:org/payroll --ledger mydb fluree graph drop http://example.org/graphs/scratch --ledger mydb:feature-x # Via a tracked remote server fluree graph drop urn:example:org/payroll --ledger mydb --remote origin ``` **Output (committed):** ``` Dropped graph from 'mydb:main' — retracted 42 flakes (t=18). ``` **Output (no-op):** ``` Graph in 'mydb:main' was already empty — no commit produced (t=17). ``` ## See Also - [drop](drop.md) — drop a whole ledger or graph source - [branch](branch.md) — branch management (drop, list, rebase, merge, diff) - [info](info.md) — full ledger info, including the underlying `named-graphs` payload - [Datasets and named graphs](../concepts/datasets-and-named-graphs.md) — concept doc - [server-integration](server-integration.md) — wire contract for custom servers (`POST /drop-graph`, `GET /info`) --- # cli/insert.md # fluree insert Insert data into a ledger. ## Usage ```bash fluree insert [LEDGER] [DATA] [OPTIONS] ``` ## Arguments | Arguments | Behavior | |-----------|----------| | (none) | Active ledger; provide data via `-e`, `-f`, or stdin | | `` | Auto-detected: if it looks like data (JSON, Turtle), uses it inline with the active ledger; if it's an existing file, reads from it; otherwise treats it as a ledger name | | ` ` | Specified ledger + inline data | ## Options | Option | Description | |--------|-------------| | `-e, --expr ` | Inline data expression (alternative to positional) | | `-f, --file ` | Read data from a file | | `-m, --message ` | Commit message | | `--format ` | Data format: `turtle` or `jsonld` (auto-detected if omitted) | | `--remote ` | Execute against a remote server (by remote name, e.g., `origin`) | ## Description Inserts RDF data into a ledger. Supports both Turtle and JSON-LD formats. Data can come from: - A positional argument (inline data) - `-e` flag (inline expression) - `-f` flag (file) - Standard input (pipe) ## Examples ```bash # Insert inline Turtle fluree insert '@prefix ex: . ex:alice a ex:Person ; ex:name "Alice" .' # Insert inline JSON-LD fluree insert '{"@id": "ex:bob", "ex:name": "Bob"}' # Insert from file fluree insert -f data.ttl # Insert with commit message fluree insert -f data.ttl -m "Added initial users" # Insert into specific ledger fluree insert production ' a .' # Pipe from stdin cat data.ttl | fluree insert ``` ## Output ``` Committed t=1 (42 flakes) ``` With verbose mode: ``` Committed t=1 (42 flakes) Commit ID: bafybeig... ``` ## Data Format Detection The format is auto-detected: - `@prefix` or `@base` at line start → Turtle - Starts with `{` or `[` → JSON-LD - `.ttl` or `.nt` file extension → Turtle (N-Triples is parsed as Turtle) - `.json` or `.jsonld` extension → JSON-LD Override with `--format turtle` or `--format jsonld`. ## See Also - [upsert](upsert.md) - Insert or update existing data - [update](update.md) - Full WHERE/DELETE/INSERT updates - [query](query.md) - Query the inserted data - [export](export.md) - Export all data --- # cli/upsert.md # fluree upsert Upsert data into a ledger (insert or update existing). ## Usage ```bash fluree upsert [LEDGER] [DATA] [OPTIONS] ``` ## Arguments | Arguments | Behavior | |-----------|----------| | (none) | Active ledger; provide data via `-e`, `-f`, or stdin | | `` | Auto-detected: if it looks like data (JSON, Turtle), uses it inline with the active ledger; if it's an existing file, reads from it; otherwise treats it as a ledger name | | ` ` | Specified ledger + inline data | ## Options | Option | Description | |--------|-------------| | `-e, --expr ` | Inline data expression (alternative to positional) | | `-f, --file ` | Read data from a file | | `-m, --message ` | Commit message | | `--format ` | Data format: `turtle` or `jsonld` (auto-detected if omitted) | | `--remote ` | Execute against a remote server (by remote name, e.g., `origin`) | ## Description Upserts RDF data into a ledger. Unlike `insert`, upsert will: - Insert new entities - Replace existing values for entities that already exist (matched by `@id`) This is useful for updating data without needing to know whether it exists. ## Examples ```bash # Update or insert a user fluree upsert '@prefix ex: . ex:alice ex:name "Alice Smith" ; ex:age 31 .' # Upsert from file fluree upsert -f updates.ttl # Upsert with commit message fluree upsert '{"@id": "ex:alice", "ex:status": "active"}' -m "Updated Alice status" ``` ## Output ``` Committed t=2 (3 flakes) ``` ## Difference from Insert | Operation | Existing Entity | New Entity | |-----------|-----------------|------------| | `insert` | Adds new triples (may create duplicates) | Creates entity | | `upsert` | Replaces values for given predicates | Creates entity | ## See Also - [insert](insert.md) - Insert without replacement - [update](update.md) - Full WHERE/DELETE/INSERT updates - [query](query.md) - Query data - [history](history.md) - View change history --- # cli/update.md # fluree update Update data with full WHERE/DELETE/INSERT semantics. ## Usage ```bash fluree update [LEDGER] [DATA] [OPTIONS] ``` ## Arguments | Arguments | Behavior | |-----------|----------| | (none) | Active ledger; provide data via `-e`, `-f`, or stdin | | `` | Auto-detected: if it looks like data (JSON or SPARQL UPDATE), uses it inline with the active ledger; if it's an existing file, reads from it; otherwise treats it as a ledger name | | ` ` | Specified ledger + inline data | ## Options | Option | Description | |--------|-------------| | `-e, --expr ` | Inline data expression (alternative to positional) | | `-f, --file ` | Read data from a file | | `-m, --message ` | Commit message | | `--format ` | Data format: `jsonld` or `sparql` (auto-detected if omitted) | | `--remote ` | Execute against a remote server (by remote name) | | `--direct` | Bypass auto-routing through a local server (global flag; see note on SPARQL UPDATE below) | ## Description Executes a WHERE/DELETE/INSERT transaction against a ledger. Unlike `insert` (which only adds data) and `upsert` (which replaces by subject+predicate), `update` supports the full WHERE/DELETE/INSERT pattern, enabling: - **Conditional deletes**: delete triples matching a WHERE pattern - **Conditional updates**: delete old values and insert new ones based on WHERE matches - **Computed updates**: use variables from WHERE to derive new values via `bind` - **Delete-only operations**: WHERE + DELETE without INSERT - **Insert-only operations**: equivalent to `insert` but using the update command ### Supported Formats - **JSON-LD** (default): transaction body with `where`, `delete`, and/or `insert` keys - **SPARQL UPDATE**: standard `INSERT DATA`, `DELETE DATA`, `DELETE/INSERT WHERE` syntax ### SPARQL UPDATE Note SPARQL UPDATE requires the server's parsing pipeline. It works automatically when: - A local server is running (the CLI auto-routes through it by default) - Using `--remote` to target a remote server For direct local mode (`--direct`), use JSON-LD format instead. ## Examples ### Conditional Property Update (JSON-LD) ```bash # Update Alice's age: find old value, delete it, insert new one fluree update '{ "@context": {"ex": "http://example.org/"}, "where": [{"@id": "ex:alice", "ex:age": "?oldAge"}], "delete": [{"@id": "ex:alice", "ex:age": "?oldAge"}], "insert": [{"@id": "ex:alice", "ex:age": 31}] }' ``` ### Delete-Only ```bash # Remove all email addresses for alice fluree update '{ "@context": {"ex": "http://example.org/"}, "where": [{"@id": "ex:alice", "ex:email": "?email"}], "delete": [{"@id": "ex:alice", "ex:email": "?email"}] }' ``` ### Bulk Conditional Update ```bash # Set all "pending" users to "active" fluree update '{ "@context": {"ex": "http://example.org/"}, "where": [{"@id": "?person", "ex:status": "pending"}], "delete": [{"@id": "?person", "ex:status": "pending"}], "insert": [{"@id": "?person", "ex:status": "active"}] }' ``` ### From File ```bash fluree update -f update.json fluree update -f update.json -m "Updated user statuses" ``` ### SPARQL UPDATE (via server) ```bash # Requires a running server (fluree server start) fluree update -e 'PREFIX ex: DELETE { ex:alice ex:age ?oldAge } INSERT { ex:alice ex:age 31 } WHERE { ex:alice ex:age ?oldAge }' ``` ### Pipe from stdin ```bash cat update.json | fluree update ``` ### Target a specific ledger ```bash fluree update production -f migration.json ``` ## Output ``` Committed t=3, 4 flakes ``` With remote mode, the full server response is printed as JSON. ## Format Detection The format is auto-detected using this priority: 1. **Explicit flag** (`--format`) — always wins 2. **File extension** (when using `-f` or a positional file path): - `.json`, `.jsonld` → JSON-LD - `.rq`, `.ru`, `.sparql` → SPARQL UPDATE 3. **Content sniffing**: - Valid JSON (full parse, not just first character) → JSON-LD - Starts with `INSERT`, `DELETE`, `PREFIX`, or `BASE` → SPARQL UPDATE Override with `--format jsonld` or `--format sparql`. ## Comparison with Insert and Upsert | Operation | WHERE clause | DELETE | Conditional | Use case | |-----------|-------------|--------|-------------|----------| | `insert` | No | No | No | Add new data | | `upsert` | No | Auto (per subject+predicate) | No | Replace values for known entities | | `update` | Yes | Explicit | Yes | Targeted updates, deletes, complex transformations | ## See Also - [insert](insert.md) - Insert new data - [upsert](upsert.md) - Insert or replace existing data - [Update (WHERE/DELETE/INSERT)](../transactions/update-where-delete-insert.md) - Full transaction syntax guide - [query](query.md) - Query data --- # cli/query.md # fluree query Query a ledger. ## Usage ```bash fluree query [LEDGER] [QUERY] [OPTIONS] ``` ## Arguments | Arguments | Behavior | |-----------|----------| | (none) | Active ledger; provide query via `-e`, `-f`, or stdin | | `` | Auto-detected: if it looks like a query, uses it inline with the active ledger; if it's an existing file, reads from it; otherwise treats it as a ledger name | | ` ` | Specified ledger + inline query | ## Options | Option | Description | |--------|-------------| | `-e, --expr ` | Inline query expression (alternative to positional) | | `-f, --file ` | Read query from a file | | `--format ` | Output format: `json`, `typed-json`, `table`, `csv`, `tsv`, or `ndjson` (default: `table`) | | `--envelope` | With `--format ndjson`, emit the full streaming record protocol verbatim instead of bare binding objects | | `--sparql` | Force SPARQL query format | | `--jsonld` | Force JSON-LD query format | | `--at