2023-03-30 18:30:46 +00:00
|
|
|
use crate::ctx::Context;
|
|
|
|
use crate::dbs::Options;
|
|
|
|
use crate::dbs::Statement;
|
|
|
|
use crate::doc::Document;
|
|
|
|
use crate::err::Error;
|
|
|
|
use crate::sql::paths::EDGE;
|
|
|
|
use crate::sql::paths::IN;
|
|
|
|
use crate::sql::paths::OUT;
|
|
|
|
use crate::sql::value::Value;
|
|
|
|
|
|
|
|
impl<'a> Document<'a> {
|
|
|
|
pub async fn reset(
|
|
|
|
&mut self,
|
2023-05-06 00:15:03 +00:00
|
|
|
_ctx: &Context<'_>,
|
|
|
|
_opt: &Options,
|
2023-03-30 18:30:46 +00:00
|
|
|
_stm: &Statement<'_>,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
// Get the record id
|
|
|
|
let rid = self.id.as_ref().unwrap();
|
|
|
|
// Set default field values
|
2023-05-06 00:15:03 +00:00
|
|
|
self.current.to_mut().def(rid);
|
2023-03-30 18:30:46 +00:00
|
|
|
// Ensure edge fields are reset
|
|
|
|
if self.initial.pick(&*EDGE).is_true() {
|
2023-04-29 15:58:22 +00:00
|
|
|
self.current.to_mut().put(&*EDGE, Value::Bool(true));
|
2023-03-30 18:30:46 +00:00
|
|
|
self.current.to_mut().put(&*IN, self.initial.pick(&*IN));
|
|
|
|
self.current.to_mut().put(&*OUT, self.initial.pick(&*OUT));
|
|
|
|
}
|
|
|
|
// Carry on
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|