Only check fields if the document is a table record
This commit is contained in:
parent
cd5ec21164
commit
8e283ecaeb
1 changed files with 21 additions and 18 deletions
|
@ -112,24 +112,27 @@ impl<'a> Document<'a> {
|
|||
_ => Err(Error::Ignore),
|
||||
},
|
||||
}?;
|
||||
// Loop through all field statements
|
||||
for fd in self.fd(opt, txn).await?.iter() {
|
||||
// Loop over each field in document
|
||||
for k in out.each(&fd.name).iter() {
|
||||
// Process field permissions
|
||||
match &fd.permissions.select {
|
||||
Permission::Full => (),
|
||||
Permission::None => out.del(ctx, opt, txn, k).await?,
|
||||
Permission::Specific(e) => {
|
||||
// Get the current value
|
||||
let val = self.current.pick(k);
|
||||
// Configure the context
|
||||
let mut ctx = Context::new(ctx);
|
||||
ctx.add_value("value".into(), val);
|
||||
let ctx = ctx.freeze();
|
||||
// Process the PERMISSION clause
|
||||
if !e.compute(&ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
|
||||
out.del(&ctx, opt, txn, k).await?
|
||||
// Check if this record exists
|
||||
if self.id.is_some() {
|
||||
// Loop through all field statements
|
||||
for fd in self.fd(opt, txn).await?.iter() {
|
||||
// Loop over each field in document
|
||||
for k in out.each(&fd.name).iter() {
|
||||
// Process field permissions
|
||||
match &fd.permissions.select {
|
||||
Permission::Full => (),
|
||||
Permission::None => out.del(ctx, opt, txn, k).await?,
|
||||
Permission::Specific(e) => {
|
||||
// Get the current value
|
||||
let val = self.current.pick(k);
|
||||
// Configure the context
|
||||
let mut ctx = Context::new(ctx);
|
||||
ctx.add_value("value".into(), val);
|
||||
let ctx = ctx.freeze();
|
||||
// Process the PERMISSION clause
|
||||
if !e.compute(&ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
|
||||
out.del(&ctx, opt, txn, k).await?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue