How to use the realm.open function in realm

To help you get started, we’ve selected a few realm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github billmalarky / react-native-queue / config / Database.js View on Github external
static async getRealmInstance(options = {}) {

    // Connect to realm if database singleton instance has not already been created.
    if (Database.realmInstance === null) {

      Database.realmInstance = await Realm.open({
        path: options.realmPath || Config.REALM_PATH,
        schemaVersion: Config.REALM_SCHEMA_VERSION,
        schema: [JobSchema]

        // Look up shouldCompactOnLaunch to auto-vacuum https://github.com/realm/realm-js/pull/1209/files

      });

    }

    return Database.realmInstance;

  }
github appideasDOTcom / APPideasLights / mobile-app / react-native / AppideasLights / app / screens / HomeScreen.js View on Github external
render() 
	  {
		const { navigate } = this.props.navigation;
		
		nodeArray = [];

		// get the list of controllers to pass to the next screen
		Realm.open( { schema: [Schema_Controller, Schema_Light] } )
		.then(
			function( realm )
			{
				let savedControllers = realm.objects( 'Controller' ).sorted( 'position' );
				for( let i = 0; i < savedControllers.length; i++ )
				{
					let currentController = savedControllers[i];
					var data = { 
							"position": currentController.position,
							"ipAddr": currentController.ipAddr, 
							"niceName": currentController.niceName,
							"strip1Id": currentController.strip1Id,
							"strip2Id": currentController.strip2Id,
						};
					nodeArray.push( data );
				}
github appideasDOTcom / APPideasLights / mobile-app / react-native / AppideasLights / app / screens / ConfigScreen.js View on Github external
deleteDataItem()
	{
		const classState = this.state;
		
		Realm.open( { schema: [Schema_Controller, Schema_Light] } )
		.then(
			function( realm )
			{
				// remove connectged lights
				var filter = 'id = ' + classState.dataStrip1Id + ' OR id = ' + classState.dataStrip2Id;
				let removeLights = realm.objects( 'Light' ).filtered( 'id = ' + classState.dataStrip1Id + ' OR id = ' + classState.dataStrip2Id  );
				realm.beginTransaction();
				for( let i = 0; i < removeLights.length; i++ )
				{
					let currentLight = removeLights[i];
					realm.delete( currentLight );
				}
				realm.commitTransaction();
				
				// delete the controller
				var positionString = "position = " + classState.dataPosition;
github Mic-J-Lee / Android-only-youniverse / src / App.js View on Github external
componentWillMount() {
    UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true)
    let dimensions = Dimensions.get('screen')
    Dimensions.addEventListener('change', () => {
      dimensions = Dimensions.get('screen')
      this.setState({ dimensions })
    })
    Realm.open({
deleteRealmIfMigrationNeeded: true, //        MUST REMOVE THIS LINE IN PRODUCTION!!!!!!!!!
      schema: [ UserSchema, GameSchema ]
    }).then(realm => {
      realm.write(() => {
        !realm.objects('Game')[0] && realm.create('Game', {})
        // users = realm.objects('User')
        // for (let user of users) realm.delete(user)
      })
      this.setState({ realm, dimensions })
      this.setState({
        rainbow: {
          red:    realm.objects('Game')[0].red,
          orange: realm.objects('Game')[0].orange,
          yellow: realm.objects('Game')[0].yellow,
          green:  realm.objects('Game')[0].green,
          blue:   realm.objects('Game')[0].blue,
github realm / realm-js / tests / js / open-behavior-tests.js View on Github external
.then(user => {
                const config = user.createConfiguration({
                    sync: {
                        fullSynchronization: true,
                        _sessionStopPolicy: 'immediately',
                        newRealmFileBehavior: {
                            type: 'downloadBeforeOpen'
                        },
                        url: 'realm://127.0.0.1:9080/new_realm_' + Utils.uuid()
                    }
                });

                let promise = Realm.open(config);
                promise.cancel();
                return promise;
            })
            .then(realm => {
github realm / realm-js / tests / js / session-tests.js View on Github external
async testResumePause() {
        const user = await Realm.Sync.User.register('http://127.0.0.1:9080', Utils.uuid(), 'password');
        const config = {
            sync: {
                user: user,
                url: 'realm://127.0.0.1:9080/~/testResumePause',
                fullSynchronization: true,
            }
        };

        const realm = await Realm.open(config);
        const session = realm.syncSession;
        await waitForConnectionState(session, Realm.Sync.ConnectionState.Connected);

        session.pause();
        await waitForConnectionState(session, Realm.Sync.ConnectionState.Disconnected);

        session.resume();
        await waitForConnectionState(session, Realm.Sync.ConnectionState.Connected);
    },
github EsecuBit / EsecuBit-react-native-wallet / app / db / RealmDB.js View on Github external
updateAccount(account) {
    account = wrapper.account.wrap(account)
    return Realm.open(this._config).then(realm => realm.write(() => {
      realm.create('Account', account, true)
    }))
  }
github EsecuBit / EsecuBit-react-native-wallet / app / db / RealmDB.js View on Github external
deleteAddressInfos(addressInfos) {
    addressInfos = wrapper.addressInfo.wraps(addressInfos)
    return Realm.open(this._config).then(realm => {
      let realmObjs = realm.objects('AddressInfo')
      addressInfos.forEach(addressInfo => {
        let objs = realmObjs.filtered(`accountId_path = "${addressInfo.accountId_path}"`)
        realm.delete(objs)
      })
    })
  }