Struct indexed_db::ObjectStore
source · pub struct ObjectStore<Err> { /* private fields */ }
Expand description
Wrapper for IDBObjectStore
,
for use in transactions
Implementations§
source§impl<Err> ObjectStore<Err>
impl<Err> ObjectStore<Err>
sourcepub fn add(
&self,
value: &JsValue
) -> impl Future<Output = Result<JsValue, Error<Err>>>
pub fn add( &self, value: &JsValue ) -> impl Future<Output = Result<JsValue, Error<Err>>>
Add the value val
to this object store, and return its auto-computed key
This will error if the key already existed.
Internally, this uses IDBObjectStore::add
.
sourcepub fn add_kv(
&self,
key: &JsValue,
value: &JsValue
) -> impl Future<Output = Result<(), Error<Err>>>
pub fn add_kv( &self, key: &JsValue, value: &JsValue ) -> impl Future<Output = Result<(), Error<Err>>>
Add the value val
to this object store, with key key
This will error if the key already existed.
Internally, this uses IDBObjectStore::add
.
sourcepub fn put(
&self,
value: &JsValue
) -> impl Future<Output = Result<JsValue, Error<Err>>>
pub fn put( &self, value: &JsValue ) -> impl Future<Output = Result<JsValue, Error<Err>>>
Sets the value val
to this object store, and return its auto-computed key
This will overwrite the previous value if the key already existed.
Internally, this uses IDBObjectStore::add
.
sourcepub fn put_kv(
&self,
key: &JsValue,
value: &JsValue
) -> impl Future<Output = Result<(), Error<Err>>>
pub fn put_kv( &self, key: &JsValue, value: &JsValue ) -> impl Future<Output = Result<(), Error<Err>>>
Add the value val
to this object store, with key key
This will overwrite the previous value if the key already existed.
Internally, this uses IDBObjectStore::add
.
sourcepub fn clear(&self) -> impl Future<Output = Result<(), Error<Err>>>
pub fn clear(&self) -> impl Future<Output = Result<(), Error<Err>>>
Clears this object store
Internally, this uses IDBObjectStore::clear
.
sourcepub fn count(&self) -> impl Future<Output = Result<usize, Error<Err>>>
pub fn count(&self) -> impl Future<Output = Result<usize, Error<Err>>>
Counts the number of objects in this store
Internally, this uses IDBObjectStore::count
.
sourcepub fn contains(
&self,
key: &JsValue
) -> impl Future<Output = Result<bool, Error<Err>>>
pub fn contains( &self, key: &JsValue ) -> impl Future<Output = Result<bool, Error<Err>>>
Checks whether the provided key exists in this object store
Internally, this uses IDBObjectStore::count
.
sourcepub fn count_in(
&self,
range: impl RangeBounds<JsValue>
) -> impl Future<Output = Result<usize, Error<Err>>>
pub fn count_in( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<usize, Error<Err>>>
Counts the number of objects with a key in range
Note that the unbounded range is not a valid range for IndexedDB.
Internally, this uses IDBObjectStore::count
.
sourcepub fn delete(
&self,
key: &JsValue
) -> impl Future<Output = Result<(), Error<Err>>>
pub fn delete( &self, key: &JsValue ) -> impl Future<Output = Result<(), Error<Err>>>
Delete the object with key key
Unfortunately, the IndexedDb API does not indicate whether an object was actually deleted.
Internally, this uses IDBObjectStore::delete
.
sourcepub fn delete_range(
&self,
range: impl RangeBounds<JsValue>
) -> impl Future<Output = Result<(), Error<Err>>>
pub fn delete_range( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<(), Error<Err>>>
Delete all the objects with a key in range
Note that the unbounded range is not a valid range for IndexedDB. Unfortunately, the IndexedDb API does not indicate whether an object was actually deleted.
Internally, this uses IDBObjectStore::delete
.
sourcepub fn get(
&self,
key: &JsValue
) -> impl Future<Output = Result<Option<JsValue>, Error<Err>>>
pub fn get( &self, key: &JsValue ) -> impl Future<Output = Result<Option<JsValue>, Error<Err>>>
Get the object with key key
Internally, this uses IDBObjectStore::get
.
sourcepub fn get_first_in(
&self,
range: impl RangeBounds<JsValue>
) -> impl Future<Output = Result<Option<JsValue>, Error<Err>>>
pub fn get_first_in( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<Option<JsValue>, Error<Err>>>
Get the first value with a key in range
, ordered by key
Note that the unbounded range is not a valid range for IndexedDB.
Internally, this uses IDBObjectStore::get
.
sourcepub fn get_all(
&self,
limit: Option<u32>
) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
pub fn get_all( &self, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
Get all the objects in the store, with a maximum number of results of limit
Internally, this uses IDBObjectStore::getAll
.
sourcepub fn get_all_in(
&self,
range: impl RangeBounds<JsValue>,
limit: Option<u32>
) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
pub fn get_all_in( &self, range: impl RangeBounds<JsValue>, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
Get all the objects with a key in the provided range, with a maximum number of results of limit
Internally, this uses IDBObjectStore::getAll
.
sourcepub fn get_first_key_in(
&self,
range: impl RangeBounds<JsValue>
) -> impl Future<Output = Result<Option<JsValue>, Error<Err>>>
pub fn get_first_key_in( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<Option<JsValue>, Error<Err>>>
Get the first existing key in the provided range
Internally, this uses IDBObjectStore::getKey
.
sourcepub fn get_all_keys(
&self,
limit: Option<u32>
) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
pub fn get_all_keys( &self, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
List all the keys in the object store, with a maximum number of results of limit
Internally, this uses IDBObjectStore::getAllKeys
.
sourcepub fn get_all_keys_in(
&self,
range: impl RangeBounds<JsValue>,
limit: Option<u32>
) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
pub fn get_all_keys_in( &self, range: impl RangeBounds<JsValue>, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, Error<Err>>>
List all the keys in the provided range, with a maximum number of results of limit
Internally, this uses IDBObjectStore::getAllKeys
.