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),
|
_ => Err(Error::Ignore),
|
||||||
},
|
},
|
||||||
}?;
|
}?;
|
||||||
// Loop through all field statements
|
// Check if this record exists
|
||||||
for fd in self.fd(opt, txn).await?.iter() {
|
if self.id.is_some() {
|
||||||
// Loop over each field in document
|
// Loop through all field statements
|
||||||
for k in out.each(&fd.name).iter() {
|
for fd in self.fd(opt, txn).await?.iter() {
|
||||||
// Process field permissions
|
// Loop over each field in document
|
||||||
match &fd.permissions.select {
|
for k in out.each(&fd.name).iter() {
|
||||||
Permission::Full => (),
|
// Process field permissions
|
||||||
Permission::None => out.del(ctx, opt, txn, k).await?,
|
match &fd.permissions.select {
|
||||||
Permission::Specific(e) => {
|
Permission::Full => (),
|
||||||
// Get the current value
|
Permission::None => out.del(ctx, opt, txn, k).await?,
|
||||||
let val = self.current.pick(k);
|
Permission::Specific(e) => {
|
||||||
// Configure the context
|
// Get the current value
|
||||||
let mut ctx = Context::new(ctx);
|
let val = self.current.pick(k);
|
||||||
ctx.add_value("value".into(), val);
|
// Configure the context
|
||||||
let ctx = ctx.freeze();
|
let mut ctx = Context::new(ctx);
|
||||||
// Process the PERMISSION clause
|
ctx.add_value("value".into(), val);
|
||||||
if !e.compute(&ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
|
let ctx = ctx.freeze();
|
||||||
out.del(&ctx, opt, txn, k).await?
|
// 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