diff --git a/dependencies.list b/dependencies.list index 05504312..abced8be 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js VERSION=1.0.2 -REALM_CORE_VERSION=2.3.1 -REALM_SYNC_VERSION=1.2.0 +REALM_CORE_VERSION=2.3.2 +REALM_SYNC_VERSION=1.3.0 REALM_OBJECT_SERVER_VERSION=1.0.3 diff --git a/src/js_realm.hpp b/src/js_realm.hpp index a1a50e55..6df9b9f1 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -148,6 +148,9 @@ class RealmClass : public ClassDefinition> { using NativeAccessor = realm::NativeAccessor; public: + using ObjectDefaultsMap = typename Schema::ObjectDefaultsMap; + using ConstructorMap = typename Schema::ConstructorMap; + static FunctionType create_constructor(ContextType); // methods @@ -173,6 +176,8 @@ public: // static methods static void constructor(ContextType, ObjectType, size_t, const ValueType[]); + static SharedRealm create_shared_realm(ContextType, realm::Realm::Config, bool, ObjectDefaultsMap &&, ConstructorMap &&); + static void schema_version(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); static void clear_test_state(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); static void copy_bundled_realm_files(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); @@ -318,8 +323,8 @@ static inline void convert_outdated_datetime_columns(const SharedRealm &realm) { template void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) { realm::Realm::Config config; - typename Schema::ObjectDefaultsMap defaults; - typename Schema::ConstructorMap constructors; + ObjectDefaultsMap defaults; + ConstructorMap constructors; bool schema_updated = false; if (argc == 0) { @@ -412,9 +417,21 @@ void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t config.path = normalize_path(config.path); ensure_directory_exists_for_file(config.path); + auto realm = create_shared_realm(ctx, config, schema_updated, std::move(defaults), std::move(constructors)); + + // Fix for datetime -> timestamp conversion + convert_outdated_datetime_columns(realm); + + set_internal>(this_object, new SharedRealm(realm)); +} + +template +SharedRealm RealmClass::create_shared_realm(ContextType ctx, realm::Realm::Config config, bool schema_updated, + ObjectDefaultsMap && defaults, ConstructorMap && constructors) { config.execution_context = reinterpret_cast(Context::get_execution_context_id(ctx)); SharedRealm realm = realm::Realm::get_shared_realm(config); + GlobalContextType global_context = Context::get_global_context(ctx); if (!realm->m_binding_context) { realm->m_binding_context.reset(new RealmDelegate(realm, global_context)); @@ -430,10 +447,7 @@ void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t js_binding_context->m_constructors = std::move(constructors); } - // Fix for datetime -> timestamp conversion - convert_outdated_datetime_columns(realm); - - set_internal>(this_object, new SharedRealm(realm)); + return realm; } template diff --git a/src/object-store b/src/object-store index e464af06..5a00a269 160000 --- a/src/object-store +++ b/src/object-store @@ -1 +1 @@ -Subproject commit e464af06104edede94ffd2de4465ab014a6337b9 +Subproject commit 5a00a269ffcfbcc4c27b40a6dcf761f9b54fcc02