mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-26 06:21:07 +00:00
Exposing a Realms groups compute_aggregated_byte_size via computeSize
This commit is contained in:
parent
8a7d7a30a5
commit
10c127542b
@ -237,6 +237,7 @@ public:
|
|||||||
static void delete_model(ContextType, ObjectType, Arguments, ReturnValue &);
|
static void delete_model(ContextType, ObjectType, Arguments, ReturnValue &);
|
||||||
static void object_for_object_id(ContextType, ObjectType, Arguments, ReturnValue&);
|
static void object_for_object_id(ContextType, ObjectType, Arguments, ReturnValue&);
|
||||||
static void privileges(ContextType, ObjectType, Arguments, ReturnValue&);
|
static void privileges(ContextType, ObjectType, Arguments, ReturnValue&);
|
||||||
|
static void compute_size(ContextType, ObjectType, Arguments, ReturnValue&);
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
static void get_empty(ContextType, ObjectType, ReturnValue &);
|
static void get_empty(ContextType, ObjectType, ReturnValue &);
|
||||||
@ -295,6 +296,7 @@ public:
|
|||||||
{"writeCopyTo", wrap<writeCopyTo>},
|
{"writeCopyTo", wrap<writeCopyTo>},
|
||||||
{"deleteModel", wrap<delete_model>},
|
{"deleteModel", wrap<delete_model>},
|
||||||
{"privileges", wrap<privileges>},
|
{"privileges", wrap<privileges>},
|
||||||
|
{"computeSize", wrap<compute_size>},
|
||||||
{"_objectForObjectId", wrap<object_for_object_id>},
|
{"_objectForObjectId", wrap<object_for_object_id>},
|
||||||
#if REALM_ENABLE_SYNC
|
#if REALM_ENABLE_SYNC
|
||||||
{"_waitForDownload", wrap<wait_for_download_completion>},
|
{"_waitForDownload", wrap<wait_for_download_completion>},
|
||||||
@ -1176,5 +1178,14 @@ void RealmClass<T>::privileges(ContextType ctx, ObjectType this_object, Argument
|
|||||||
return_value.set(object);
|
return_value.set(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void RealmClass<T>::compute_size(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) {
|
||||||
|
args.validate_maximum(0);
|
||||||
|
|
||||||
|
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||||
|
auto size = realm->read_group().compute_aggregated_byte_size();
|
||||||
|
return_value.set(Value::from_number(ctx, size));
|
||||||
|
}
|
||||||
|
|
||||||
} // js
|
} // js
|
||||||
} // realm
|
} // realm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user