attribute
Module[Attribute]: attribute definitions before they are created.
Contents
Structs
AttributeAn attribute definition the collection can take: a new key (in the metadata and, with schema attributes, in the table), the filters and format its type needs, within the attribute count and row width limits, a supported type of a valid size, and a default of its type.AttributeOptionsUndocumented.use utopia_database::validator::attribute::Attribute;Rust
pub struct AttributeAn attribute definition the collection can take: a new key (in the metadata and, with schema attributes, in the table), the filters and format its type needs, within the attribute count and row width limits, a supported type of a valid size, and a default of its type.
Rust
use utopia_database::Document;
use utopia_database::validator::attribute::{Attribute, AttributeOptions};
use utopia_database::value::{Value, string};
let validator = Attribute::new(&[], &[], AttributeOptions { max_string_length: 1000, ..Default::default() });
let title = Document::from_pairs([("$id", string("title")), ("type", string("string")), ("size", Value::Int(2000))]).unwrap();
assert_eq!(validator.check(&title).unwrap_err().message(), "Max size allowed for string is: 1,000");use utopia_database::validator::attribute::AttributeOptions;Rust
pub struct AttributeOptionsUndocumented.
Rust
pub type Filter = Box<dyn Fn(&str) -> String + Send + Sync>Undocumented.
Rust
pub type Measure = Box<dyn Fn(&Document) -> Result<i64> + Send + Sync>Undocumented.