pub struct Database { /* private fields */ }Expand description
The main database interface.
Provides methods for:
- Creating and dropping tables
- CRUD operations (insert, select, update, delete)
- Transaction management
- Observable queries
Implementations§
Source§impl Database
impl Database
Sourcepub async fn create(name: &str) -> Result<Database, JsValue>
pub async fn create(name: &str) -> Result<Database, JsValue>
Async factory method for creating a database (for WASM compatibility).
Sourcepub fn create_table(&self, name: &str) -> JsTableBuilder
pub fn create_table(&self, name: &str) -> JsTableBuilder
Creates a new table builder.
Sourcepub fn register_table(&self, builder: &JsTableBuilder) -> Result<(), JsValue>
pub fn register_table(&self, builder: &JsTableBuilder) -> Result<(), JsValue>
Registers a table schema with the database.
Sourcepub fn table_names(&self) -> Array
pub fn table_names(&self) -> Array
Returns all table names.
Sourcepub fn table_count(&self) -> usize
pub fn table_count(&self) -> usize
Returns the number of tables.
Sourcepub fn select(&self, columns: &JsValue) -> SelectBuilder
pub fn select(&self, columns: &JsValue) -> SelectBuilder
Starts a SELECT query. Accepts either:
- A single string: select(‘*’) or select(‘name’)
- Multiple strings: select(‘name’, ‘score’) - passed as variadic args
Sourcepub fn insert(&self, table: &str) -> InsertBuilder
pub fn insert(&self, table: &str) -> InsertBuilder
Starts an INSERT operation.
Sourcepub fn update(&self, table: &str) -> UpdateBuilder
pub fn update(&self, table: &str) -> UpdateBuilder
Starts an UPDATE operation.
Sourcepub fn delete(&self, table: &str) -> DeleteBuilder
pub fn delete(&self, table: &str) -> DeleteBuilder
Starts a DELETE operation.
Sourcepub fn transaction(&self) -> JsTransaction
pub fn transaction(&self) -> JsTransaction
Begins a new transaction.
Sourcepub fn clear_table(&self, name: &str) -> Result<(), JsValue>
pub fn clear_table(&self, name: &str) -> Result<(), JsValue>
Clears data from a specific table.
Sourcepub fn total_row_count(&self) -> usize
pub fn total_row_count(&self) -> usize
Returns the total row count across all tables.
Trait Implementations§
Source§impl FromWasmAbi for Database
impl FromWasmAbi for Database
Source§impl IntoWasmAbi for Database
impl IntoWasmAbi for Database
Source§impl LongRefFromWasmAbi for Database
impl LongRefFromWasmAbi for Database
Source§impl OptionFromWasmAbi for Database
impl OptionFromWasmAbi for Database
Source§impl OptionIntoWasmAbi for Database
impl OptionIntoWasmAbi for Database
Source§impl RefFromWasmAbi for Database
impl RefFromWasmAbi for Database
Source§impl RefMutFromWasmAbi for Database
impl RefMutFromWasmAbi for Database
Source§impl TryFromJsValue for Database
impl TryFromJsValue for Database
Source§impl VectorFromWasmAbi for Database
impl VectorFromWasmAbi for Database
Source§impl VectorIntoWasmAbi for Database
impl VectorIntoWasmAbi for Database
impl SupportsConstructor for Database
impl SupportsInstanceProperty for Database
impl SupportsStaticProperty for Database
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
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.