2022-05-14 12:35:08 +00:00
|
|
|
use crate::ctx::Context;
|
2022-02-06 01:14:56 +00:00
|
|
|
use crate::dbs::Options;
|
|
|
|
use crate::dbs::Statement;
|
2022-02-15 01:00:30 +00:00
|
|
|
use crate::dbs::Transaction;
|
2022-02-06 01:14:56 +00:00
|
|
|
use crate::doc::Document;
|
|
|
|
use crate::err::Error;
|
|
|
|
use crate::sql::value::Value;
|
2022-01-13 07:00:50 +00:00
|
|
|
|
2022-02-13 19:03:00 +00:00
|
|
|
impl<'a> Document<'a> {
|
2022-02-06 01:14:56 +00:00
|
|
|
pub async fn create(
|
|
|
|
&mut self,
|
2022-05-14 12:35:08 +00:00
|
|
|
ctx: &Context<'_>,
|
2022-02-06 21:06:52 +00:00
|
|
|
opt: &Options,
|
2022-02-15 03:33:16 +00:00
|
|
|
txn: &Transaction,
|
2022-05-13 20:46:56 +00:00
|
|
|
stm: &Statement<'_>,
|
2022-02-06 01:14:56 +00:00
|
|
|
) -> Result<Value, Error> {
|
2022-03-31 23:35:35 +00:00
|
|
|
// Check if exists
|
|
|
|
self.exist(ctx, opt, txn, stm).await?;
|
2022-05-30 15:32:26 +00:00
|
|
|
// Alter record data
|
|
|
|
self.alter(ctx, opt, txn, stm).await?;
|
2022-04-04 22:26:54 +00:00
|
|
|
// Merge fields data
|
|
|
|
self.field(ctx, opt, txn, stm).await?;
|
2022-07-04 16:54:43 +00:00
|
|
|
// Clean fields data
|
|
|
|
self.clean(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Check if allowed
|
2022-02-15 01:00:30 +00:00
|
|
|
self.allow(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Store index data
|
2022-02-15 01:00:30 +00:00
|
|
|
self.index(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Store record data
|
2022-02-15 01:00:30 +00:00
|
|
|
self.store(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Run table queries
|
2022-02-15 01:00:30 +00:00
|
|
|
self.table(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Run lives queries
|
2022-02-15 01:00:30 +00:00
|
|
|
self.lives(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Run event queries
|
2022-02-15 01:00:30 +00:00
|
|
|
self.event(ctx, opt, txn, stm).await?;
|
2022-02-06 01:14:56 +00:00
|
|
|
// Yield document
|
2022-02-15 01:00:30 +00:00
|
|
|
self.pluck(ctx, opt, txn, stm).await
|
2022-02-06 01:14:56 +00:00
|
|
|
}
|
|
|
|
}
|