surrealdb_sql/statements/remove/
mod.rs1mod analyzer;
2mod database;
3mod event;
4mod field;
5mod function;
6mod index;
7mod model;
8mod namespace;
9mod param;
10mod scope;
11mod table;
12mod token;
13mod user;
14
15pub use analyzer::RemoveAnalyzerStatement;
16pub use database::RemoveDatabaseStatement;
17pub use event::RemoveEventStatement;
18pub use field::RemoveFieldStatement;
19pub use function::RemoveFunctionStatement;
20pub use index::RemoveIndexStatement;
21pub use model::RemoveModelStatement;
22pub use namespace::RemoveNamespaceStatement;
23pub use param::RemoveParamStatement;
24pub use scope::RemoveScopeStatement;
25pub use table::RemoveTableStatement;
26pub use token::RemoveTokenStatement;
27pub use user::RemoveUserStatement;
28
29use crate::ctx::Context;
30use crate::dbs::{Options, Transaction};
31use crate::doc::CursorDoc;
32use crate::err::Error;
33use crate::Value;
34use derive::Store;
35use revision::revisioned;
36use serde::{Deserialize, Serialize};
37use std::fmt::{self, Display, Formatter};
38
39#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
40#[revisioned(revision = 1)]
41pub enum RemoveStatement {
42 Namespace(RemoveNamespaceStatement),
43 Database(RemoveDatabaseStatement),
44 Function(RemoveFunctionStatement),
45 Analyzer(RemoveAnalyzerStatement),
46 Token(RemoveTokenStatement),
47 Scope(RemoveScopeStatement),
48 Param(RemoveParamStatement),
49 Table(RemoveTableStatement),
50 Event(RemoveEventStatement),
51 Field(RemoveFieldStatement),
52 Index(RemoveIndexStatement),
53 User(RemoveUserStatement),
54 Model(RemoveModelStatement),
55}
56
57impl RemoveStatement {
58 pub(crate) fn writeable(&self) -> bool {
60 true
61 }
62 pub(crate) async fn compute(
64 &self,
65 ctx: &Context<'_>,
66 opt: &Options,
67 txn: &Transaction,
68 _doc: Option<&CursorDoc<'_>>,
69 ) -> Result<Value, Error> {
70 match self {
71 Self::Namespace(ref v) => v.compute(ctx, opt, txn).await,
72 Self::Database(ref v) => v.compute(ctx, opt, txn).await,
73 Self::Function(ref v) => v.compute(ctx, opt, txn).await,
74 Self::Token(ref v) => v.compute(ctx, opt, txn).await,
75 Self::Scope(ref v) => v.compute(ctx, opt, txn).await,
76 Self::Param(ref v) => v.compute(ctx, opt, txn).await,
77 Self::Table(ref v) => v.compute(ctx, opt, txn).await,
78 Self::Event(ref v) => v.compute(ctx, opt, txn).await,
79 Self::Field(ref v) => v.compute(ctx, opt, txn).await,
80 Self::Index(ref v) => v.compute(ctx, opt, txn).await,
81 Self::Analyzer(ref v) => v.compute(ctx, opt, txn).await,
82 Self::User(ref v) => v.compute(ctx, opt, txn).await,
83 Self::Model(ref v) => v.compute(ctx, opt, txn).await,
84 }
85 }
86}
87
88impl Display for RemoveStatement {
89 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
90 match self {
91 Self::Namespace(v) => Display::fmt(v, f),
92 Self::Database(v) => Display::fmt(v, f),
93 Self::Function(v) => Display::fmt(v, f),
94 Self::Token(v) => Display::fmt(v, f),
95 Self::Scope(v) => Display::fmt(v, f),
96 Self::Param(v) => Display::fmt(v, f),
97 Self::Table(v) => Display::fmt(v, f),
98 Self::Event(v) => Display::fmt(v, f),
99 Self::Field(v) => Display::fmt(v, f),
100 Self::Index(v) => Display::fmt(v, f),
101 Self::Analyzer(v) => Display::fmt(v, f),
102 Self::User(v) => Display::fmt(v, f),
103 Self::Model(v) => Display::fmt(v, f),
104 }
105 }
106}