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

View file

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

View file

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

View file

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