= Collections and documents :nav-title: Collections & Documents :description: Browse, create, edit and delete your app's data from the console, and the same operations over the API: filter, sort, page, and partial updates. :keywords: MongoDB collections, documents, browse data, CRUD API, filter and sort, JSON documents, data browser :group: Your data :order: 10 Your app's data lives in collections of JSON documents. The console shows them under **Collections**: the list of collections first, then the documents of the one you open. Everything you do here is one API call, shown next to each action, so your app can do the same. == Collections image::/assets/docs-images/collections.png[The Collections browser: the collections of the service, with the system ones marked] The list shows every collection of the service. On Dedicated, a database selector at the top picks the database. The system collections (`users`, `acl`, `_schemas`, `gql-apps`) are listed but managed from their own pages. **Create one** with **New Collection**: a name, and optionally a xref:schemas.adoc[JSON Schema] that every document must match. A collection whose name ends in `.files` is a file bucket, and the console treats its rows as files with a download link. **The gear** opens the collection's metadata: the schema bound to it, and the `aggrs` and `streams` arrays that the xref:aggregations.adoc[Aggregations] and xref:change-streams.adoc[Change streams] pages manage. You can bind a schema from here. **The bin** deletes the collection and every document in it, after a confirmation. [cols="2,3"] |=== | Operation | API | List collections | `GET /` (`GET /` on Dedicated) | Create collection | `PUT /` | Read metadata | `GET //_meta` | Bind a schema | `PATCH /` with `{ "jsonSchema": { "schemaId": "" } }` | Delete collection | `DELETE /` |=== == Documents Open a collection to see its documents. image::/assets/docs-images/documents.png[The documents of a collection, with filter, sort and projection fields above the list] **Find** what you want with the three fields at the top. They are the `filter`, `sort` and `keys` parameters of the API, and the list refreshes as you type: [cols="1,3"] |=== | Field | What to type | Filter | A MongoDB query, such as `{"status": "active"}` or `{"age": {"$gt": 18}}`. | Sort | `{"createdAt": -1}` for newest first, `{"name": 1}` for A to Z. | Keys | A projection, `{"name": 1, "email": 1}`, to show only some fields. |=== **New** opens a JSON editor for a document. Leave `_id` out and MongoDB assigns one. **Edit** on a row opens the document in place. Saving sends a `PATCH` with the fields you changed: fields you did not touch are kept. **Delete** on a row removes the document, after a confirmation. The console handles every kind of `_id`: an ObjectId, a string, a number or a date. In a filter, an ObjectId is written `{"_id": {"$oid": "..."}}` and a date `{"$date": "..."}`. [cols="2,3"] |=== | Operation | API | Read, filter, sort, page | `GET /?filter={...}&sort={...}&keys={...}&page=1&pagesize=20` | Create | `POST /` with the document as the body | Update some fields | `PATCH //` with only the fields to change | Replace | `PUT //` with the whole document | Delete | `DELETE //` | Download a file | `GET /.files//binary` |=== From your app these are plain HTTPS calls with the user's credentials. What each user may read and write is decided by xref:managing-permissions.adoc[permissions], and a `readFilter` there can limit a user to their own documents without the app knowing. The full query language, with paging, projections and aggregation-style operators, is in the link:{restheart-docs}/mongodb-rest/read-docs[REST API reference]. == Related pages * xref:schemas.adoc[Schemas]: refuse a document that does not match. * xref:managing-indexes.adoc[Indexes]: keep filters and sorts fast as the collection grows. * xref:change-streams.adoc[Change streams]: let the UI know when a document changes. * xref:plans.adoc[Plans]: the database selector and the paths on Dedicated.