Merge pull request #343 from esteemapp/feature/realm-version

Added realm version fixed #336
This commit is contained in:
Feruz M 2019-01-05 19:32:21 +02:00 committed by GitHub
commit c6aeba0765

View File

@ -73,8 +73,24 @@ const authSchema = {
const realm = new Realm({
path: 'esteem.realm',
schema: [userSchema, authSchema, draftSchema, settingsSchema, applicationSchema, scAccounts],
schemaVersion: 0,
migration,
});
const migration = (oldRealm, newRealm) => {
// EXAMPLE
// // only apply this change if upgrading to schemaVersion 1
// if (oldRealm.schemaVersion < 1) {
// const oldObjects = oldRealm.objects('Person');
// const newObjects = newRealm.objects('Person');
// // loop through all objects and set the name property in the new schema
// for (let i = 0; i < oldObjects.length; i++) {
// newObjects[i].name = `${oldObjects[i].firstName} ${oldObjects[i].lastName}`;
// }
// }
};
const settings = realm.objects(SETTINGS_SCHEMA);
if (Array.from(settings).length <= 0) {