diff --git a/Realm.xcworkspace/contents.xcworkspacedata b/Realm.xcworkspace/contents.xcworkspacedata
index bd9650bf..9eb61350 100644
--- a/Realm.xcworkspace/contents.xcworkspacedata
+++ b/Realm.xcworkspace/contents.xcworkspacedata
@@ -14,6 +14,6 @@
location = "group:examples/ReactExample/ios/ReactExample.xcodeproj">
+ location = "group:src/node/RealmNode.xcodeproj">
diff --git a/src/ios/platform.mm b/src/ios/platform.mm
index 94373209..be7e4473 100644
--- a/src/ios/platform.mm
+++ b/src/ios/platform.mm
@@ -66,11 +66,10 @@ void ensure_directory_exists_for_file(const std::string &fileName)
void copy_bundled_realm_files()
{
+ NSString *docsDir = @(default_realm_file_directory().c_str());
+ NSFileManager *manager = [NSFileManager defaultManager];
for (id bundle in [NSBundle allBundles]) {
NSString *resourcePath = [bundle resourcePath];
- NSString *docsDir = @(default_realm_file_directory().c_str());
- NSFileManager *manager = [NSFileManager defaultManager];
-
for (NSString *path in [manager enumeratorAtPath:resourcePath]) {
if (![path containsString:@".realm"]) {
continue;
diff --git a/src/js_realm.hpp b/src/js_realm.hpp
index 9852e2dd..200cab4e 100644
--- a/src/js_realm.hpp
+++ b/src/js_realm.hpp
@@ -253,6 +253,31 @@ inline typename T::Function Realm::create_constructor(ContextType ctx) {
return realm_constructor;
}
+
+void convert_outdated_datetime_columns(SharedRealm realm) {
+ if (realm->config().upgrade_initial_version != realm->config().upgrade_final_version &&
+ realm->config().upgrade_initial_version < 5) {
+ // any versions earlier than file format 5 are stored as milliseconds and need to be converted to the new format
+ for (auto& object_schema : *realm->config().schema) {
+ auto table = ObjectStore::table_for_object_type(realm->read_group(), object_schema.name);
+ for (auto& property : object_schema.properties) {
+ if (property.type == PropertyTypeDate) {
+ if (!realm->is_in_transaction()) {
+ realm->begin_transaction();
+ }
+
+ for (size_t row_index = 0; row_index < table->size(); row_index++) {
+ auto milliseconds = table->get_timestamp(property.table_column, row_index).get_seconds();
+ table->set_timestamp(property.table_column, row_index, Timestamp(milliseconds / 1000, (milliseconds % 1000) * 1000000));
+ }
+ }
+ }
+ if (realm->is_in_transaction()) {
+ realm->commit_transaction();
+ }
+ }
+ }
+}
template
void Realm::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) {
@@ -365,28 +390,7 @@ void Realm::constructor(ContextType ctx, ObjectType this_object, size_t argc,
}
// Fix for datetime -> timestamp conversion
- if (realm->config().upgrade_initial_version != realm->config().upgrade_final_version &&
- realm->config().upgrade_initial_version < 5) {
- // any versions earlier than file format 5 are stored as milliseconds and need to be converted to the new format
- for (auto object_schema : *realm->config().schema) {
- auto table = ObjectStore::table_for_object_type(realm->read_group(), object_schema.name);
- for (auto property : object_schema.properties) {
- if (property.type == PropertyTypeDate) {
- if (!realm->is_in_transaction()) {
- realm->begin_transaction();
- }
-
- for (size_t row_index = 0; row_index < table->size(); row_index++) {
- auto milliseconds = table->get_timestamp(property.table_column, row_index).get_seconds();
- table->set_timestamp(property.table_column, row_index, Timestamp(milliseconds / 1000, (milliseconds % 1000) * 1000000));
- }
- }
- }
- if (realm->is_in_transaction()) {
- realm->commit_transaction();
- }
- }
- }
+ convert_outdated_datetime_columns(realm);
set_internal>(this_object, new SharedRealm(realm));
}