operator
Module[Operator]: an atomic update of one attribute (increment, array
append, string concat, ...), given as an attribute value of an update.
Rust
use utopia_database::{Operator, Value};
use utopia_database::operator::OperatorMethod;
let mut op = Operator::increment(5, Some(100.into()));
op.set_attribute("score");
assert_eq!(op.to_string().unwrap(), r#"{"method":"increment","attribute":"score","values":[5,100]}"#);
assert_eq!(*Operator::parse(r#"{"method":"toggle"}"#).unwrap().method(), OperatorMethod::Toggle);
assert!(Operator::divide(0, None).is_err());
assert!(Operator::is_operator(&Value::from(Operator::toggle())));Contents
use utopia_database::operator::Extracted;Rust
pub struct ExtractedThe operators and plain values of an update's data.
use utopia_database::Operator;Rust
pub struct OperatorOne operator.
use utopia_database::operator::Number;Rust
pub enum NumberUndocumented.
Also implements
From.use utopia_database::operator::OperatorMethod;Rust
pub enum OperatorMethodAn operator method (Operator::TYPE_*).
Also implements
Display.Rust
pub const ARRAY_FILTER_CONDITIONS: [&str; 8] = ["equal", "notEqual", "greaterThan", "greaterThanEqual", "lessThan", "lessThanEqual", "isNull", "isNotNull"]The conditions arrayFilter accepts.
Rust
pub const MAX_ARRAY_OPERATOR_SIZE: usize = 10000The most values one array operator (append, prepend, intersect, diff) may carry.
Rust
pub const TYPES: [OperatorMethod; 20] = [ OperatorMethod::Increment, OperatorMethod::Decrement, OperatorMethod::Multiply, OperatorMethod::Divide, OperatorMethod::Modulo, OperatorMethod::Power, OperatorMethod::StringConcat, OperatorMethod::StringReplace, OperatorMethod::ArrayAppend, OperatorMethod::ArrayPrepend, OperatorMethod::ArrayInsert, OperatorMethod::ArrayRemove, OperatorMethod::ArrayUnique, OperatorMethod::ArrayIntersect, OperatorMethod::ArrayDiff, OperatorMethod::ArrayFilter, OperatorMethod::Toggle, OperatorMethod::DateAddDays, OperatorMethod::DateSubDays, OperatorMethod::DateSetNow, ]Undocumented.