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
/ /
SDK de Dispositivo Atlas

Upgrade from Stitch to Realm - React Native SDK

If you have an existing app built with the Stitch SDK, you should migrate your app to use the new Realm SDK. While much of the application logic and flow of information hasn't changed, there are a few changes to how it connects to the Atlas App Services backend.

Nota

Esta página presenta cómo migrar del SDK MongoDB Stitch React Native al SDK Realm JS para crear aplicaciones React Native.

If you are looking to use the Realm JS SDK to build Node.js applications, check out the Upgrade from Stitch to Realm Node.js page. If you are looking to build web apps, consider our Upgrade from Stitch to Realm Web page.

  • El SDK Realm JS ahora incluye Realm base de datos, que cuenta con almacenamiento local de objetos y la capacidad de sincronizar cambios en documentos entre dispositivos a través de Internet.

¿Qué ha cambiado?
Solución

Las conexiones de la aplicación backend a las que anteriormente se accedía a través de Cliente de StitchAppya están disponibles a través de Realm.App. Usa el Realm.App Clase para acceder a la funcionalidad de autenticación, como iniciar sesión y obtener el usuario actual.

Migrate all occurrences of StitchAppClient to Realm.App.

StitchUser was previously the interface to access application users, but now it is Realm.User.

Migrate all occurrences of StitchUser to Realm.User.

La API de inicio de sesión ha cambiado de stitchAppClient.auth.loginWithCredential() a Realm.App.logIn()

Rewrite all authentication logic to use the new login API.

The API to log users out has changed from stitchAppClient.auth.logout() to Realm.User.logOut().

Rewrite the application logic to log out using the Realm.User object's logOut() method.

El SDK de Stitch requería que los desarrolladores importaran credenciales de autenticación desde el "mongodb-stitch-server-sdk". El SDK de Realm tiene una clase, Realm.Credentials, que crea credenciales para cada proveedor de autenticación.

Replace imports of authentication credentials with method calls for each respective authentication provider through the Realm.Credentials class.

Instead of calling Atlas Functions using the app client directly via the method stitchAppClient.callFunction(), you must call server Atlas Functions using the callFunction() method of a logged-in Realm.User.

Call Functions using Realm.User.callFunction() instead of an app client.

La interfaz de la API de acceso a datos de MongoDB, que contiene objetos como MongoDatabase y MongoCollection, ha cambiado. Mediante Stitch, al pasar RemoteMongoClient.Factory y la cadena "mongodb-atlas" a StitchAppClient.getServiceClient() se crea un cliente remoto de MongoDB. El SDK de Realm JS crea un cliente remoto de MongoDB mediante el método Realm.User.mongoClient en el objeto de usuario.

Reemplace todas las instancias mongoClient con Realm.User.mongoClient.

Los SDK de Realm no proporcionan una interfaz para llamar a servicios (como los servicios Twilio y AWS).

Convierte las referencias a servicios de terceros (AWS o Twilio) en tu aplicación de Stitch en funciones Realm de tu aplicación Realm usando los paquetes npm correspondientes. Para más información, consulta Agregar dependencias externas.

En esta página