diff --git a/CHANGELOG.md b/CHANGELOG.md index ce4c42a9..13ad0c4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +x.x.x Release notes (xxxx-xx-xx) +============================================================= +### Compatibility + +### Breaking changes +* None. + +### Enhancements +* None + +### Bug fixes +* Fix `Realm.open()` to work without passing a config. + +### Internal + + 2.6.0 Release notes (2018-5-16) ============================================================= ### Compatibility diff --git a/docs/realm.js b/docs/realm.js index dde42326..dc4b001e 100644 --- a/docs/realm.js +++ b/docs/realm.js @@ -105,7 +105,7 @@ class Realm { /** * Open a Realm asynchronously with a promise. If the Realm is synced, it will be fully * synchronized before it is available. - * @param {Realm~Configuration} config + * @param {Realm~Configuration} config - if no config is defined, it will open the default realm * @returns {ProgressPromise} - a promise that will be resolved with the Realm instance when it's available. */ static open(config) {} diff --git a/lib/extensions.js b/lib/extensions.js index 505bdf51..691ea757 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -64,6 +64,9 @@ module.exports = function(realmConstructor) { //Add async open API Object.defineProperties(realmConstructor, getOwnPropertyDescriptors({ open(config) { + // If no config is defined, we should just open the default realm + if (config === undefined) { config = {}; } + // For local Realms we open the Realm and return it in a resolved Promise. if (!("sync" in config)) { let promise = Promise.resolve(new realmConstructor(config)); diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 878ad8d8..777ede1d 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -222,6 +222,21 @@ module.exports = { }); }, + testRealmOpenNoConfig: function() { + let realm = new Realm({schema: [schemas.TestObject], schemaVersion: 1}); + realm.write(() => { + realm.create('TestObject', [1]) + }); + realm.close(); + + return Realm.open().then(realm => { + const objects = realm.objects('TestObject'); + TestCase.assertEqual(objects.length, 1); + TestCase.assertEqual(objects[0].doubleCol, 1.0); + realm.close(); + }); + }, + testDefaultPath: function() { const defaultPath = Realm.defaultPath; let defaultRealm = new Realm({schema: []});