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 build_index<'a>(
&self,
name: &'a str,
key_path: &[&str]
) -> IndexBuilder<'a, Err>
pub fn build_index<'a>( &self, name: &'a str, key_path: &[&str] ) -> IndexBuilder<'a, Err>
Build an index over this object store
Note that this method can only be called from within an on_upgrade_needed
callback. It returns
a builder, and calling the create
method on this builder will perform the actual creation.
Internally, this uses IDBObjectStore::createIndex
.
sourcepub fn delete_index(&self, name: &str) -> Result<(), Err>
pub fn delete_index(&self, name: &str) -> Result<(), Err>
Delete an index from this object store
Note that this method can only be called from within an on_upgrade_needed
callback. It returns
a builder, and calling the create
method on this builder will perform the actual creation.
Internally, this uses IDBObjectStore::deleteIndex
.
sourcepub fn add(&self, value: &JsValue) -> impl Future<Output = Result<JsValue, Err>>
pub fn add(&self, value: &JsValue) -> impl Future<Output = Result<JsValue, 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<(), Err>>
pub fn add_kv( &self, key: &JsValue, value: &JsValue ) -> impl Future<Output = Result<(), 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, Err>>
pub fn put(&self, value: &JsValue) -> impl Future<Output = Result<JsValue, 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<(), Err>>
pub fn put_kv( &self, key: &JsValue, value: &JsValue ) -> impl Future<Output = Result<(), 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<(), Err>>
pub fn clear(&self) -> impl Future<Output = Result<(), Err>>
Clears this object store
Internally, this uses IDBObjectStore::clear
.
sourcepub fn count(&self) -> impl Future<Output = Result<usize, Err>>
pub fn count(&self) -> impl Future<Output = Result<usize, 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, Err>>
pub fn contains(&self, key: &JsValue) -> impl Future<Output = Result<bool, 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, Err>>
pub fn count_in( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<usize, 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<(), Err>>
pub fn delete(&self, key: &JsValue) -> impl Future<Output = Result<(), 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<(), Err>>
pub fn delete_range( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<(), 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>, Err>>
pub fn get( &self, key: &JsValue ) -> impl Future<Output = Result<Option<JsValue>, 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>, Err>>
pub fn get_first_in( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<Option<JsValue>, 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>, Err>>
pub fn get_all( &self, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, 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>, Err>>
pub fn get_all_in( &self, range: impl RangeBounds<JsValue>, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, 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>, Err>>
pub fn get_first_key_in( &self, range: impl RangeBounds<JsValue> ) -> impl Future<Output = Result<Option<JsValue>, 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>, Err>>
pub fn get_all_keys( &self, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, 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>, Err>>
pub fn get_all_keys_in( &self, range: impl RangeBounds<JsValue>, limit: Option<u32> ) -> impl Future<Output = Result<Vec<JsValue>, Err>>
List all the keys in the provided range, with a maximum number of results of limit
Internally, this uses IDBObjectStore::getAllKeys
.
sourcepub fn index(&self, name: &str) -> Result<Index<Err>, Err>
pub fn index(&self, name: &str) -> Result<Index<Err>, Err>
Get the Index
with the provided name
Internally, this uses IDBObjectStore::index
.
sourcepub fn cursor(&self) -> CursorBuilder<Err>
pub fn cursor(&self) -> CursorBuilder<Err>
Open a Cursor
on this object store