SurrealDB Docs Logo

Enter a search query

unset()

Removes a parameter from this connection.

Method Syntax
db.unset(key)

Example usage

use serde::Serialize; use surrealdb::engine::remote::ws::Ws; use surrealdb::opt::auth::Root; use surrealdb::Surreal; #[derive(Debug, Serialize)] struct Name<'a> { first: &'a str, last: &'a str, } #[tokio::main] async fn main() -> surrealdb::Result<()> { let db = Surreal::new::<Ws>("127.0.0.1:8000").await?; db.signin(Root { username: "root", password: "root", }) .await?; db.use_ns("ns").use_db("db").await?; // Assign the variable on the connection db.set( "name", Name { first: "Tobie", last: "Morgan Hitchcock", }, ) .await?; dbg!(db.query("RETURN $name").await?); db.unset("name").await?; // Aaaand now it's gone dbg!(db.query("RETURN $name").await?); Ok(()) }

See also

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install