Process document fields correctly
This commit is contained in:
parent
e378105f11
commit
6b6d4f65f9
1 changed files with 93 additions and 90 deletions
|
@ -19,10 +19,12 @@ impl<'a> Document<'a> {
|
|||
) -> Result<(), Error> {
|
||||
// Loop through all field statements
|
||||
for fd in self.fd(opt, txn).await?.iter() {
|
||||
// Loop over each field in document
|
||||
for k in self.current.each(&fd.name).into_iter() {
|
||||
// Get the initial value
|
||||
let old = self.initial.get(ctx, opt, txn, &fd.name).await?;
|
||||
let old = self.initial.pick(&k);
|
||||
// Get the current value
|
||||
let mut val = self.current.get(ctx, opt, txn, &fd.name).await?;
|
||||
let mut val = self.current.pick(&k);
|
||||
// Check for a VALUE clause
|
||||
if let Some(expr) = &fd.value {
|
||||
// Configure the context
|
||||
|
@ -111,11 +113,12 @@ impl<'a> Document<'a> {
|
|||
}
|
||||
// Set the value of the field
|
||||
match val {
|
||||
Value::None => self.current.to_mut().del(ctx, opt, txn, &fd.name).await?,
|
||||
Value::Void => self.current.to_mut().del(ctx, opt, txn, &fd.name).await?,
|
||||
_ => self.current.to_mut().set(ctx, opt, txn, &fd.name, val).await?,
|
||||
Value::None => self.current.to_mut().del(ctx, opt, txn, &k).await?,
|
||||
Value::Void => self.current.to_mut().del(ctx, opt, txn, &k).await?,
|
||||
_ => self.current.to_mut().set(ctx, opt, txn, &k, val).await?,
|
||||
};
|
||||
}
|
||||
}
|
||||
// Carry on
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue