surrealpatch/src/doc/compute.rs
Tobie Morgan Hitchcock efa67bb043 Only pass transaction when processing queries
Instead of passing the executor instance, we only need to pass the current transaction which is to be used for processing and running any queries.
2022-02-15 01:05:39 +00:00

27 lines
800 B
Rust

use crate::dbs::Options;
use crate::dbs::Runtime;
use crate::dbs::Statement;
use crate::dbs::Transaction;
use crate::doc::Document;
use crate::err::Error;
use crate::sql::value::Value;
impl<'a> Document<'a> {
pub async fn compute(
&mut self,
ctx: &Runtime,
opt: &Options,
txn: &Transaction<'_>,
stm: &Statement<'_>,
) -> Result<Value, Error> {
match stm {
Statement::Select(_) => self.select(ctx, opt, txn, stm).await,
Statement::Create(_) => self.create(ctx, opt, txn, stm).await,
Statement::Update(_) => self.update(ctx, opt, txn, stm).await,
Statement::Relate(_) => self.relate(ctx, opt, txn, stm).await,
Statement::Delete(_) => self.delete(ctx, opt, txn, stm).await,
Statement::Insert(_) => self.insert(ctx, opt, txn, stm).await,
_ => unreachable!(),
}
}
}