Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
React Native SDK

Trabajar con archivos de Realm - React Native SDK

Realms are the core data structure used to organize data in Realm Database. At its core, a realm is a collection of the objects that you use in your application, called Realm objects, as well as additional metadata that describe the objects.

Realm almacena una versión codificada en binario de cada objeto y tipo en un reino en un solo .realm archivo. El archivo se encuentra en una ruta específica que usted define al abrir el reino.

Tip

Implemente la compactación en su aplicación de producción

Cada aplicación de producción debe implementar una función de retorno shouldCompactOnLaunch para reducir periódicamente el tamaño del archivo Realm.

Realm crea archivos adicionales para cada realm:

  • archivos realm, con el sufijo "realm", por ejemplo, default.realm: contiene datos de objetos.

  • lock files, suffixed with "lock", e.g. default.realm.lock: keep track of which versions of data in a realm are actively in use. This prevents realm from reclaiming storage space that is still used by a client application.

  • note files, suffixed with "note", e.g. default.realm.note: enable inter-thread and inter-process notifications.

  • archivos de gestión, con el sufijo "gestión", pordefault.realm.management ejemplo: gestión del estado interno.

If you delete a realm file or any of its auxiliary files while one or more instances of the realm are open, you might corrupt the realm or disrupt sync.

You may safely delete these files when all instances of a realm are closed. Before you delete a realm file, make sure that you back up any important objects as you will lose all unsynced data in the realm.

You can also open a realm entirely in memory, which will not create a .realm file or its associated auxiliary files. Instead the SDK stores objects in memory while the realm is open and discards them immediately when all instances are closed.

The realm file is located at a specific path that you can optionally define when you open the realm.

// Open a realm.
const realm = await Realm.open({
schema: [Car],
});
// Get on-disk location of the Realm
const realmFileLocation = realm.path;
console.log(`Realm file is located at: ${realm.path}`);

Volver

React Native SDK

En esta página