From 2b89702490596d87aed44793b4d7a3468b3eda7f Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 6 Apr 2022 19:44:55 +0100 Subject: [PATCH] Improve code comments --- lib/src/doc/allow.rs | 4 ++-- lib/src/doc/check.rs | 2 ++ lib/src/doc/field.rs | 2 ++ lib/src/doc/pluck.rs | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/doc/allow.rs b/lib/src/doc/allow.rs index 1dcdbc8b..5e1a0ae5 100644 --- a/lib/src/doc/allow.rs +++ b/lib/src/doc/allow.rs @@ -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(()), diff --git a/lib/src/doc/check.rs b/lib/src/doc/check.rs index f7a65a92..5cd96684 100644 --- a/lib/src/doc/check.rs +++ b/lib/src/doc/check.rs @@ -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); } } diff --git a/lib/src/doc/field.rs b/lib/src/doc/field.rs index c02d7388..4a99d89e 100644 --- a/lib/src/doc/field.rs +++ b/lib/src/doc/field.rs @@ -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, diff --git a/lib/src/doc/pluck.rs b/lib/src/doc/pluck.rs index db88da4d..c6a242ed 100644 --- a/lib/src/doc/pluck.rs +++ b/lib/src/doc/pluck.rs @@ -19,8 +19,8 @@ impl<'a> Document<'a> { ) -> Result { // 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),