Document service
The document service provides storage for all types of data. The primary use case for document service is to store user-centric, self-contained data typically produced and maintained by apps.
Concepts
You need to know the following concepts to work with the document service.
Document
Every document consists of metadata and content. The metadata contains information such as the document name and timestamps, which you can use to filter and sort your documents.
Following are some essential things to remember about documents:
- The document service generates a unique ID for each document and doesn't rely on the document's name for identification. Therefore, document names don't have to be unique.
- The content of documents isn't indexed. Therefore, you can't search the contents of a document.
- You must ensure that the content for each document doesn't exceed the maximum size.
The document service is entirely agnostic of the content and the content type.
Ownership
The user who creates a document becomes the owner of that document. The owner has permission to share and delete the document. Only the owner can access the document unless the owner shares it with others.
Admin access
Users with elevated privileges may request admin access and act with the same permissions as a document's owner. An admin has permission to access and modify documents created by any user of the same environment.
Sharing documents
Users can share the document with other users. The document owner can grant either read-only or read-write access to the document for other users. Document service also prevents accidental overwriting due to collaboration using optimistic locking
There are three ways a user can share documents:
- Public: A document's owner can grant read-only access to the document to all users of the same environment.
- Environment: A document's owner can grant access to the document to all users of the same environment. Each user must opt in individually.
- Direct: A document's owner can grant specific users or groups access to a document.
All apps can access a document, even when the owner is restricting access to the document.
Restore deleted documents
Deleting a document moves it into the trash and makes it inaccessible. The document service will automatically delete documents in the trash after some time. Alternatively, users can manually delete a document from the trash if they don't want to wait for the automatic deletion. Users can restore a document from the trash, making it accessible and sparing it from permanent deletion.
Restore previous document states
Users can create snapshots of documents. Subsequent updates to the document don't affect these snapshots. If needed, users can restore a snapshot later. This action resets the document to its state when the snapshot was created.
Restoring a snapshot affects only the document's content. It doesn't change access-related data like the document's shares or ownership.
Creating snapshots is rate-limited per user and document. The document service will delete snapshots automatically after some time. Each document allows for a maximum number of snapshots.
Data consistency
The document service guarantees eventual consistency.