surrealpatch/core/src/doc/create.rs

45 lines
1.2 KiB
Rust
Raw Normal View History

use crate::ctx::Context;
2024-05-28 10:43:45 +00:00
use crate::dbs::Options;
use crate::dbs::Statement;
use crate::doc::Document;
use crate::err::Error;
use crate::sql::value::Value;
use reblessive::tree::Stk;
2022-01-13 07:00:50 +00:00
2024-08-15 16:01:02 +00:00
impl Document {
pub async fn create(
&mut self,
stk: &mut Stk,
2024-08-15 16:01:02 +00:00
ctx: &Context,
opt: &Options,
stm: &Statement<'_>,
) -> Result<Value, Error> {
2024-08-15 16:01:02 +00:00
// Check if table has current relation status
2024-05-28 10:43:45 +00:00
self.relation(ctx, opt, stm).await?;
2022-05-30 15:32:26 +00:00
// Alter record data
2024-05-28 10:43:45 +00:00
self.alter(stk, ctx, opt, stm).await?;
// Merge fields data
2024-05-28 10:43:45 +00:00
self.field(stk, ctx, opt, stm).await?;
// Reset fields data
2024-05-28 10:43:45 +00:00
self.reset(ctx, opt, stm).await?;
// Clean fields data
2024-05-28 10:43:45 +00:00
self.clean(stk, ctx, opt, stm).await?;
// Check if allowed
2024-05-28 10:43:45 +00:00
self.allow(stk, ctx, opt, stm).await?;
// Store record data
2024-05-28 10:43:45 +00:00
self.store(ctx, opt, stm).await?;
// Store index data
2024-05-28 10:43:45 +00:00
self.index(stk, ctx, opt, stm).await?;
// Run table queries
2024-05-28 10:43:45 +00:00
self.table(stk, ctx, opt, stm).await?;
// Run lives queries
2024-05-28 10:43:45 +00:00
self.lives(stk, ctx, opt, stm).await?;
// Run change feeds queries
2024-05-28 10:43:45 +00:00
self.changefeeds(ctx, opt, stm).await?;
// Run event queries
2024-05-28 10:43:45 +00:00
self.event(stk, ctx, opt, stm).await?;
// Yield document
2024-05-28 10:43:45 +00:00
self.pluck(stk, ctx, opt, stm).await
}
}