pub struct Database(/* private fields */);Expand description
An IDBDatabase implementation.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open<N>(name: N) -> OpenDbRequestBuilder<N>
pub fn open<N>(name: N) -> OpenDbRequestBuilder<N>
Open a database with the given name. Convenience method for OpenDbRequestBuilder::new - use it when opening
multiple databases.
§Errors
| Error | Thrown when |
|---|---|
InvalidStateError | Thrown if the method was not called from a Versionchange transaction callback. |
TransactionInactiveError | Thrown if a request is made on a source database that does not exist (for example, when the database has been deleted or removed). |
ConstraintError | Thrown if an object store with the given name (based on a case-sensitive comparison) already exists in the connected database. |
InvalidAccessError | Thrown if autoIncrement is set to true and keyPath is either an empty string or an array containing an empty string. |
Sourcepub fn create_object_store<N>(&self, name: N) -> StoreBuilder<'_, N>
pub fn create_object_store<N>(&self, name: N) -> StoreBuilder<'_, N>
Create an object store with the given name.
Sourcepub fn delete_object_store(&self, name: &str) -> Result<(), Error>
pub fn delete_object_store(&self, name: &str) -> Result<(), Error>
Delete the object store with the given name.
§Errors
| Error | Thrown when |
|---|---|
InvalidStateError | Thrown if the method was not called from a Versionchange transaction callback. |
TransactionInactiveError | Thrown if a request is made on a source database that does not exist (for example, when the database has been deleted or removed). |
NotFoundError | Thrown when trying to delete an object store that does not exist. |
Sourcepub fn object_store_names(&self) -> DomStringIter<'_>
pub fn object_store_names(&self) -> DomStringIter<'_>
List the names of the object stores within this database.
Sourcepub fn transaction<S>(&self, store_names: S) -> TransactionBuilder<'_, S>where
S: ObjectStoreName,
pub fn transaction<S>(&self, store_names: S) -> TransactionBuilder<'_, S>where
S: ObjectStoreName,
Start a transaction on the given store name(s). Finish the builder with a call to
Build::build.
§Errors
| Error | Thrown when |
|---|---|
NotFoundError | Thrown if an object store specified cannot be found. |
InvalidAccessError | Thrown if the fn was called with an empty list of store names. |
Sourcepub fn delete_by_name(name: &str) -> Result<Request<()>, OpenDbError>
pub fn delete_by_name(name: &str) -> Result<Request<()>, OpenDbError>
Delete the database with the given name. Convenience method for DBFactory::delete_db - use that if you need
to delete more than one database.
§Errors
Undocumented as of the release of this version.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl !Send for Database
impl !Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more