Improve code comments

This commit is contained in:
Tobie Morgan Hitchcock 2022-04-06 19:44:55 +01:00
parent 2e2756d9e8
commit 2b89702490
4 changed files with 7 additions and 3 deletions

View file

@ -18,7 +18,7 @@ impl<'a> Document<'a> {
if opt.perms && opt.auth.perms() && self.id.is_some() {
// Get the table
let tb = self.tb(ctx, opt, txn).await?;
// Get the permission
// Get the permission clause
let perms = if self.initial.is_none() {
&tb.permissions.create
} else if self.current.is_none() {
@ -28,7 +28,7 @@ impl<'a> Document<'a> {
} else {
&tb.permissions.update
};
// Match the permission
// Match the permission clause
match perms {
Permission::None => return Err(Error::Ignore),
Permission::Full => return Ok(()),

View file

@ -16,6 +16,8 @@ impl<'a> Document<'a> {
// Check where condition
if let Some(cond) = stm.conds() {
if cond.expr.compute(ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
// Check if the expression is truthy
// Ignore this document
return Err(Error::Ignore);
}
}

View file

@ -87,6 +87,7 @@ impl<'a> Document<'a> {
}
// Check for a PERMISSIONS clause
if opt.perms && opt.auth.perms() {
// Get the permission clause
let perms = if self.initial.is_none() {
&fd.permissions.create
} else if self.current.is_none() {
@ -94,6 +95,7 @@ impl<'a> Document<'a> {
} else {
&fd.permissions.update
};
// Match the permission clause
match perms {
Permission::Full => (),
Permission::None => val = old,

View file

@ -19,8 +19,8 @@ impl<'a> Document<'a> {
) -> Result<Value, Error> {
// Ensure futures are run
let opt = &opt.futures(true);
// Match clause
match stm.output() {
// Process output clause
Some(v) => match v {
Output::None => Err(Error::Ignore),
Output::Null => Ok(Value::Null),