1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! # SurrealDB Field Representation
//!
//! doc wip
use vantage_expressions::Expressive;
use crate::{AnySurrealType, Expr, identifier::Identifier};
/// Represents a database field
///
/// doc wip
///
/// # Examples
///
/// ```rust
/// use vantage_surrealdb::field::Field;
///
/// // doc wip
/// let field = Field::new("user_name");
/// ```
#[derive(Debug, Clone, Hash)]
pub struct Field {
field: String,
}
impl Field {
/// Creates a new field
///
/// doc wip
///
/// # Arguments
///
/// * `field` - doc wip
pub fn new(field: impl Into<String>) -> Self {
Self {
field: field.into(),
}
}
pub fn dot(&self, field: impl Into<String>) -> Expr {
Identifier::new(self.field.clone()).dot(field.into())
}
}
impl Expressive<AnySurrealType> for Field {
fn expr(&self) -> Expr {
Identifier::new(self.field.clone()).into()
}
}