mirror of
https://github.com/perstarkse/minne.git
synced 2026-11-30 09:23:56 +01:00
email wip
This commit is contained in:
1 parent
3d941d948d
commit
9f23005210
23 files changed
+674
-189
No files matched your search
+10
-8
@@ -18,18 +18,20 @@ impl SurrealDbClient {
|
||||
///
|
||||
/// # Returns
|
||||
/// * `SurrealDbClient` initialized
|
||||
pub async fn new() -> Result<Self, Error> {
|
||||
let db = connect("ws://127.0.0.1:8000").await?;
|
||||
pub async fn new(
|
||||
address: &str,
|
||||
username: &str,
|
||||
password: &str,
|
||||
namespace: &str,
|
||||
database: &str,
|
||||
) -> Result<Self, Error> {
|
||||
let db = connect(address).await?;
|
||||
|
||||
// Sign in to database
|
||||
db.signin(Root {
|
||||
username: "root_user",
|
||||
password: "root_password",
|
||||
})
|
||||
.await?;
|
||||
db.signin(Root { username, password }).await?;
|
||||
|
||||
// Set namespace
|
||||
db.use_ns("test").use_db("test").await?;
|
||||
db.use_ns(namespace).use_db(database).await?;
|
||||
|
||||
Ok(SurrealDbClient { client: db })
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user