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> {
|
) -> Result<(), Error> {
|
||||||
// Loop through all field statements
|
// Loop through all field statements
|
||||||
for fd in self.fd(opt, txn).await?.iter() {
|
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
|
// 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
|
// 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
|
// Check for a VALUE clause
|
||||||
if let Some(expr) = &fd.value {
|
if let Some(expr) = &fd.value {
|
||||||
// Configure the context
|
// Configure the context
|
||||||
|
@ -111,11 +113,12 @@ impl<'a> Document<'a> {
|
||||||
}
|
}
|
||||||
// Set the value of the field
|
// Set the value of the field
|
||||||
match val {
|
match val {
|
||||||
Value::None => self.current.to_mut().del(ctx, opt, txn, &fd.name).await?,
|
Value::None => self.current.to_mut().del(ctx, opt, txn, &k).await?,
|
||||||
Value::Void => self.current.to_mut().del(ctx, opt, txn, &fd.name).await?,
|
Value::Void => self.current.to_mut().del(ctx, opt, txn, &k).await?,
|
||||||
_ => self.current.to_mut().set(ctx, opt, txn, &fd.name, val).await?,
|
_ => self.current.to_mut().set(ctx, opt, txn, &k, val).await?,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Carry on
|
// Carry on
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue