Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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 );
}
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;
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,
.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 => {
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);
},
updateAccount(account) {
account = wrapper.account.wrap(account)
return Realm.open(this._config).then(realm => realm.write(() => {
realm.create('Account', account, true)
}))
}
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)
})
})
}