Add Realm::get_schema_version()
This commit is contained in:
parent
1d25766ebb
commit
7fda90c3b2
|
@ -133,7 +133,7 @@ SharedRealm Realm::get_shared_realm(Config config)
|
||||||
}
|
}
|
||||||
else if (realm->m_config.read_only) {
|
else if (realm->m_config.read_only) {
|
||||||
if (old_version == ObjectStore::NotVersioned) {
|
if (old_version == ObjectStore::NotVersioned) {
|
||||||
throw UnitializedRealmException("Can't open an un-initizliazed Realm without a Schema");
|
throw UnitializedRealmException("Can't open an un-initialized Realm without a Schema");
|
||||||
}
|
}
|
||||||
ObjectStore::verify_schema(realm->read_group(), *realm->m_config.schema, true);
|
ObjectStore::verify_schema(realm->read_group(), *realm->m_config.schema, true);
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,16 @@ bool Realm::refresh()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Realm::get_schema_version(const realm::Realm::Config &config)
|
||||||
|
{
|
||||||
|
auto existing_realm = s_global_cache.get_any_realm(config.path);
|
||||||
|
if (existing_realm) {
|
||||||
|
return existing_realm->config().schema_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ObjectStore::get_schema_version(Realm(config).read_group());
|
||||||
|
}
|
||||||
|
|
||||||
SharedRealm RealmCache::get_realm(const std::string &path, std::thread::id thread_id)
|
SharedRealm RealmCache::get_realm(const std::string &path, std::thread::id thread_id)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
|
@ -76,6 +76,8 @@ namespace realm {
|
||||||
// returns if any changes were made
|
// returns if any changes were made
|
||||||
bool update_schema(Schema &schema, uint64_t version);
|
bool update_schema(Schema &schema, uint64_t version);
|
||||||
|
|
||||||
|
static uint64_t get_schema_version(Config const& config);
|
||||||
|
|
||||||
const Config &config() const { return m_config; }
|
const Config &config() const { return m_config; }
|
||||||
|
|
||||||
void begin_transaction();
|
void begin_transaction();
|
||||||
|
|
Loading…
Reference in New Issue