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
51
52
//! SurrealDB `CREATE` statement builder.
//!
//! Builds parameterized `CREATE table SET ...` or `CREATE table:id SET ...`
//! expressions for execution via [`ExprDataSource::execute()`].
//!
//! # Examples
//!
//! ```rust,ignore
//! use vantage_surrealdb::{SurrealInsert, thing::Thing};
//!
//! // Auto-generated ID
//! let ins = SurrealInsert::new("users")
//! .with_field("name", "Alice".to_string())
//! .with_field("age", 30i64);
//!
//! // Explicit ID
//! let ins = SurrealInsert::new("users")
//! .with_id("alice")
//! .with_field("name", "Alice".to_string());
//!
//! // Thing reference field
//! let ins = SurrealInsert::new("order")
//! .with_id("o1")
//! .with_field("customer", Thing::new("user", "alice"));
//!
//! // Execute
//! db.execute(&ins.expr()).await?;
//! ```
use IndexMap;
use crateIdentifier;
use crateAnySurrealType;
/// Builder for SurrealDB `CREATE` statements.
///
/// Produces `CREATE table SET key = val, ...` or `CREATE table:id SET ...`.
/// All field values are passed as parameterized CBOR values, not inlined strings.