Source: https://docs.any.org/database/index.html
# Database
any is a document database that lives on your device, syncs through an end-to-end-encrypted network, and merges concurrent edits with CRDTs. This section covers the data model and the HTTP surface for reading and writing it.
## The model in one picture
```
account
└── space encrypted, shared with members
├── objects one row per object: its property values
│ └── object one type in any.type, N collections in any.collections
│ ├── properties record[ownerId][propId]
│ └── datasets chat_messages, editor_blocks, …
├── types property definitions + parts + layout
└── collections property definitions only
```
- A **space** is the unit of sharing and encryption. Every member holds the same data; every write is a change in a per-object DAG that syncs to everyone.
- An **object** is a document. It has exactly one **type** in `any.type`, any number of **collections** in `any.collections`, property values keyed by `.` — the owner being the type or one of the collections — and any number of per-object **datasets** (records that belong to that object — chat messages, editor blocks, or a runtime dataset you declare).
- A **type** is what an object is: property definitions (kind, descriptor, scope), a **layout**, and **parts** — display units owning datasets a module serves: `records` (a runtime schema), `editor` (a block body), `chat` (a conversation). The hidden built-in types `page` and `dataview` exist in every space; your own document types are registered as bundles, and the space's chat is installed by the server's catalog.
- A **collection** is what an object is filed under: property definitions and nothing else. `miniapp` (the sidebar) and `bin` are built in; the wiki and the contact facets come from the catalog.
## One read path, many write paths
Reads always go through the windowed query primitive: `POST /v1/spaces/:spaceId/objects/query` for the cross-object `objects` storage collection and `POST /v1/spaces/:spaceId/query` for one object's dataset. Each has a `/subscribe` twin that returns the same snapshot plus a live stream of changes (see [Subscribe](https://docs.any.org/realtime/subscribe.md.txt)). Writes go through purpose-built endpoints — property set, generic `/modify`, and the modules' own handlers — and each returns the same `{versionId, changeId, recordIds}` receipt; object create answers with the new `objectId`.
> **Why it matters.** There is no server between you and your data. Queries run against a local any-store database, so a read is a local disk read, a write is immediately visible, and both work offline. Sync and merge happen underneath — the query you ran a second ago keeps answering while peers catch up.
## Where to start
1. [Spaces](https://docs.any.org/database/spaces.md.txt) — create one, read its metadata, understand its lifecycle.
2. [Objects](https://docs.any.org/database/objects.md.txt) — create objects with a type, file them under collections, delete them.
3. [Types and properties](https://docs.any.org/database/types-and-properties.md.txt) — define the shape of your data.
4. [Collections](https://docs.any.org/database/collections.md.txt) — file objects under facets that add columns.
5. [Reading data](https://docs.any.org/database/reading-data.md.txt) — the filter grammar, sort, paging.
6. [Writing data](https://docs.any.org/database/writing-data.md.txt) — property writes, `/modify` ops, the write receipt.
[**Data model** — One type, N collections and N datasets per object; schemas and scopes.](https://docs.any.org/database/data-model.md.txt)
[**Spaces** — Create, list, update and delete the encrypted containers your data lives in.](https://docs.any.org/database/spaces.md.txt)
[**Objects** — Documents with one type, any number of collections, properties and per-object datasets.](https://docs.any.org/database/objects.md.txt)
[**Types and properties** — Declare the one type an object is, with its layout, parts and property definitions.](https://docs.any.org/database/types-and-properties.md.txt)
[**Collections** — File objects under facets that add columns — the wiki, the sidebar, the bin, your own.](https://docs.any.org/database/collections.md.txt)
[**Property lifecycle** — What is pinned, what patches, what removal does.](https://docs.any.org/database/property-lifecycle.md.txt)
[**Data types** — Kinds, the xFormat descriptor, the `{"$date": …}` instant, and the synced / local / account scopes.](https://docs.any.org/database/data-types.md.txt)
[**Reading data** — Mongo-style filters, sort, limit/offset and cursor paging through /query.](https://docs.any.org/database/reading-data.md.txt)
[**Writing data** — Property writes, /modify ops, local-scope writes and the ModifyResult receipt.](https://docs.any.org/database/writing-data.md.txt)
[**Indexes** — What is indexed, what is a scan, and how to keep hot queries cheap.](https://docs.any.org/database/indexes.md.txt)
[**Runtime datasets** — Declare a dataset schema on a type at runtime and have every peer enforce it.](https://docs.any.org/database/runtime-datasets.md.txt)
[**Upsert** — Idempotent batch ingest keyed by caller-supplied record ids.](https://docs.any.org/database/upsert.md.txt)
[**Aggregation** — MongoDB-style pipelines over objects or a dataset.](https://docs.any.org/database/aggregation.md.txt)
[**Version history** — List changes, diff versions and view an object as it was.](https://docs.any.org/database/version-history.md.txt)
[**Markdown import/export** — Render blocks to markdown and import markdown back, losslessly.](https://docs.any.org/database/markdown-import-export.md.txt)
[**System fields** — The derived row-root stamps and the `\_ver` / `\_deletedAt` metadata on every record.](https://docs.any.org/database/system-fields.md.txt)
[**Derived objects** — Deterministic object ids that every device computes offline.](https://docs.any.org/database/derived-objects.md.txt)