pub struct Database { /* private fields */ }Expand description
数据库主结构
使用 enum 包装两种引擎模式,提供统一的 API
Implementations§
Source§impl Database
impl Database
Sourcepub fn drop_table(&self, name: &str) -> DbResult<()>
pub fn drop_table(&self, name: &str) -> DbResult<()>
删除表
Sourcepub fn query(&self, table: &str) -> QueryBuilder
pub fn query(&self, table: &str) -> QueryBuilder
查询构建器
内存模式:返回完整的 QueryBuilder,支持所有功能 持久化模式:同样支持 QueryBuilder(通过内部 MemoryEngine 的 Arc)
Sourcepub fn update(&self, table: &str) -> UpdateBuilder
pub fn update(&self, table: &str) -> UpdateBuilder
更新构建器
内存模式:返回完整的 UpdateBuilder,支持所有功能 持久化模式:同样支持 UpdateBuilder(通过内部 MemoryEngine 的 Arc)
Sourcepub fn delete(&self, table: &str) -> DeleteBuilder
pub fn delete(&self, table: &str) -> DeleteBuilder
删除构建器
内存模式:返回完整的 DeleteBuilder,支持所有功能 持久化模式:同样支持 DeleteBuilder(通过内部 MemoryEngine 的 Arc)
Sourcepub fn transaction<F, T>(&self, f: F) -> DbResult<T>
pub fn transaction<F, T>(&self, f: F) -> DbResult<T>
执行事务
事务在两种模式下都支持:
- 内存模式:支持回滚(通过 WriteLog)
- 持久化模式:支持回滚 + WAL 日志标记
Sourcepub fn has_composite_index(&self, table: &str, columns: &[&str]) -> bool
pub fn has_composite_index(&self, table: &str, columns: &[&str]) -> bool
检查复合索引是否存在
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 UnsafeUnpin 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