surrealdb/sql/statements/remove/
analyzer.rsuse crate::ctx::Context;
use crate::dbs::{Options, Transaction};
use crate::err::Error;
use crate::iam::{Action, ResourceKind};
use crate::sql::{Base, Ident, Value};
use derive::Store;
use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
pub struct RemoveAnalyzerStatement {
pub name: Ident,
}
impl RemoveAnalyzerStatement {
pub(crate) async fn compute(
&self,
_ctx: &Context<'_>,
opt: &Options,
txn: &Transaction,
) -> Result<Value, Error> {
opt.is_allowed(Action::Edit, ResourceKind::Analyzer, &Base::Db)?;
let mut run = txn.lock().await;
run.clear_cache();
let key = crate::key::database::az::new(opt.ns(), opt.db(), &self.name);
run.del(key).await?;
Ok(Value::None)
}
}
impl Display for RemoveAnalyzerStatement {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "REMOVE ANALYZER {}", self.name)
}
}