forked from mongodb-university/realm-tutorial-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetRealmApp.js
More file actions
28 lines (25 loc) · 829 Bytes
/
getRealmApp.js
File metadata and controls
28 lines (25 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Provides access to the Realm app instance.
//
// To get the app working with your backend, you first need to instantiate
// the Realm app. The Realm app is the interface to the MongoDB Realm backend.
import Realm from 'realm';
let app;
// Returns the shared instance of the Realm app.
// https://docs.mongodb.com/realm-sdks/js/latest/Realm.App.html
export default function getRealmApp() {
if (app === undefined) {
const appId = 'tasktracker7singapore-uuvgs'; // Set Realm app ID here.
const appConfig = {
id: appId,
timeout: 10000,
// This describes the options used for local app configuration.
app: {
name: 'default',
version: '0',
},
};
// Creates a new app and connects to a MongoDB Realm instance.
app = new Realm.App(appConfig);
}
return app;
}