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
/ /
Realm Studio

Abrir un archivo de reino

Si tienes un archivo Realm local que has creado ejecutando una aplicación cliente, puedes abrirlo en Realm Studio.

If you don't already have a realm file, you can create one by importing a CSV, or you can download a demo file.

Puede utilizar Realm Studio para abrir y explorar un archivo Realm local. Este podría ser un archivo generado al ejecutar un emulador en tu máquina local o un archivo proveniente de otra fuente. Algunas herramientas de desarrollo incluso permiten ver y editar el archivo realm mientras el emulador está en ejecución. Este flujo de trabajo admite una iteración rápida y sencilla para cambios en objetos y esquemas.

Realm stores a binary-encoded version of every object and type in a single realm file. The file is located at a specific path that you define when you open the realm.

To find your default realm file path:

// Get on-disk location of the default Realm
let realm = try! Realm()
print("Realm is located at:", realm.configuration.fileURL!)
// 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}`);

The filesystem used by Android emulators is not directly accessible from the machine running Realm Studio. You must download the file from the emulator before you can access it.

Primero, busca la ruta del archivo en el emulador:

// Run this on the device to find the path on the emulator
Realm realm = Realm.getDefaultInstance();
Log.i("Realm", realm.getPath());

Then, download the file using ADB. You can do this while the app is running.

> adb pull <path>

You can also upload the modified file again using ADB, but only when the app isn't running. Uploading a modified file while the app is running can corrupt the file.

> adb push <file> <path>
var realm = Realm.GetInstance();
Console.WriteLine($"Realm is located at: {realm.Config.DatabasePath}");
// Get on-disk location of the default Realm
final storagePath = Configuration.defaultStoragePath;
// See value in your application
print(storagePath);
config = SyncConfiguration.Builder(user, setOf(Item::class))
.initialSubscriptions { realm ->
add(
realm.query<Item>(
"owner_id == $0",
realmApp.currentUser!!.identity
),
"User's Items"
)
}
.build()
// Log on-disk location of the realm file
Log.v("My Tag", "Realm Path: ${config.path}")

Una vez que conozca la ubicación de su archivo de reino local, puede buscar esa ubicación desde el Open Realm file diálogo.

Nota

Files at hidden paths

En MacOS, la ubicación predeterminada para los archivos del emulador Xcode es en ~/Library Carpeta. Por defecto, este es un directorio oculto. Es posible que no pueda acceder a esta ubicación desde el cuadro de diálogo Open Realm file.

Use another technique to view the file, such as Go to Folder in Finder, and open the realm from there.

If you don't have a local realm file, you can create one from a CSV in Realm Studio.

Cuando creas un realm a partir de un CSV, Realm Studio infiere los siguientes detalles:

  • The name of your CSV becomes the class name in the realm file

  • The first row of your CSV becomes the class property names in the realm

  • The values of each column shape the class property types. A column of 'true' and 'false' values becomes a boolean property type. A column of whole numbers becomes an integer property type, and so on. If Realm Studio can't determine the property type, it becomes a string.

Por ejemplo, un CSV llamado data.csv con este formato:

1device,number,flag
2gizmo,1,TRUE
3widget,2,FALSE

Se convierte en un modelo de clase llamado data que tiene tres propiedades:

  • device, con un tipo string

  • number, con un tipo int

  • flag, con un tipo bool

1

En Realm Studio, vaya a: File > Create Realm from > CSV

2

Browse to the location of your CSV file, and select it.

Presiona el botón Open.

3

Enter a name for the realm file that will be created from your CSV.

Browse to the location where you want to save it.

Presiona el botón Save.

4

Cuando se crea un nuevo archivo realm a partir de un CSV, se podría recibir este mensaje:

"Error al importar datos: falta el nombre de la clase (nombre-del-archivo.csv) en el esquema"

If this happens, press OK. You'll see that creating a realm from your CSV has created a class definition, but there are no objects in your realm. From here, you can Import from a CSV to populate your realm with object that map to the class definition you just created.

Si eres nuevo en Realm y no tienes un archivo realm ni un CSV para importar, aún puedes probar Realm Studio.

Cuando abras Realm Studio, verás una opción para Download a demo Realm file.

Al hacer clic en el enlace para descargar el archivo de demostración en Realm Studio, se puede especificar un nombre y una ubicación para guardar un archivo realm que contiene datos de demostración. Una vez descargado el archivo, se puede utilizar el diálogo Open Realm file para abrirlo.

Si obtienes un error al intentar abrir un archivo realm, esto podría deberse a un desajuste de versión entre el formato de archivo Realm compatible con Realm Studio y el formato de archivo Realm creado por el SDK.

Para verificar la compatibilidad, consulte las notas de la versión de su SDK o su Versión de Realm StudioEs posible que necesites actualizar o degradar la versión de Realm Studio o del SDK de Realm.

These error messages may resemble:

Realm file is currently open in another process which cannot share access
with this process. All processes sharing a single file must be the same
architecture.
The file is already opened by another process, with an incompatible
lock file format. Try up- or downgrading Realm Studio or SDK to match
their versions of Realm Core.

Volver

Ver datos con Device Sync

En esta página