surrealpatch/lib/src/doc/check.rs

26 lines
522 B
Rust
Raw Normal View History

use crate::dbs::Options;
use crate::dbs::Runtime;
use crate::dbs::Statement;
use crate::dbs::Transaction;
use crate::doc::Document;
use crate::err::Error;
2021-03-29 15:43:37 +00:00
impl<'a> Document<'a> {
pub async fn check(
&self,
ctx: &Runtime,
opt: &Options,
txn: &Transaction,
2022-02-26 23:30:19 +00:00
stm: &Statement,
) -> Result<(), Error> {
// Check where condition
if let Some(cond) = stm.conds() {
if cond.expr.compute(ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
return Err(Error::Ignore);
}
}
// Carry on
Ok(())
}
}