surrealpatch/core/src/doc/create.rs

46 lines
1.3 KiB
Rust
Raw Normal View History

use crate::ctx::Context;
use crate::dbs::Statement;
use crate::dbs::{Options, Transaction};
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
impl<'a> Document<'a> {
pub async fn create(
&mut self,
stk: &mut Stk,
ctx: &Context<'_>,
opt: &Options,
txn: &Transaction,
stm: &Statement<'_>,
) -> Result<Value, Error> {
// Check if table has corrent relation status
self.relation(ctx, opt, txn, stm).await?;
2022-05-30 15:32:26 +00:00
// Alter record data
self.alter(stk, ctx, opt, txn, stm).await?;
// Merge fields data
self.field(stk, ctx, opt, txn, stm).await?;
// Reset fields data
self.reset(ctx, opt, txn, stm).await?;
// Clean fields data
self.clean(stk, ctx, opt, txn, stm).await?;
// Check if allowed
self.allow(stk, ctx, opt, txn, stm).await?;
// Store record data
self.store(ctx, opt, txn, stm).await?;
// Store index data
self.index(stk, ctx, opt, txn, stm).await?;
// Run table queries
self.table(stk, ctx, opt, txn, stm).await?;
// Run lives queries
self.lives(stk, ctx, opt, txn, stm).await?;
// Run change feeds queries
self.changefeeds(ctx, opt, txn, stm).await?;
// Run event queries
self.event(stk, ctx, opt, txn, stm).await?;
// Yield document
self.pluck(stk, ctx, opt, txn, stm).await
}
}