This API was turned down in January 2019 and is deprecated. Migrate to Cloud Firestore or another data store.

In-Memory Mode

In-memory mode allows you to manipulate a Realtime Document without being connected to the Realtime servers. This allows you to use the same API as with a standard document, but with a few caveats:

  • Changes are not saved to the server or automatically persisted in any way.
  • You will not receive any changes from collaborators.
  • Methods related to collaboration, like getCollaborators, will return dummy data.

This can be useful in a few scenarios:

  • Testing: Allows you to test against the real API without worrying about server state, authorization, etc.
  • Server-side document modifications: Use with the import/export API to make changes to a document without an active user.
  • An upgrade path for non-Google users: Offer a non-collaborative experience for users who do not yet have Google accounts. In this scenario, you would need to persist the contents to your own server. You can later upgrade from in-memory mode to a Drive-backed document to enable collaboration by importing into a new Drive file.

To use in-memory mode, either invoke newInMemoryDocument to create a blank document, or loadFromJson to begin from a previously exported JSON file.

To retrieve updated contents from the document, use toJson.