Rust

[Index]: index definitions against a collection's attributes and the adapter's capabilities.

Contents

use utopia_database::validator::index::Index;
Rust
pub struct Index

An index definition: a known type the adapter supports, on existing attributes (no duplicates), with lengths, orders and attribute types that suit its type, and not clashing with the collection's other indexes (a second full-text or TTL index, an identical index).

Rust
use utopia_database::Document;
use utopia_database::validator::index::{Index, IndexSupport};
use utopia_database::value::{Value, list, string};

let title = Document::from_pairs([("$id", string("title")), ("type", string("string")), ("size", Value::Int(255))]).unwrap();
let validator = Index::new(&[title], vec![], 768, vec![], IndexSupport::default());
let index = Document::from_pairs([("$id", string("idx")), ("type", string("key")), ("attributes", list([string("title")]))]).unwrap();
assert!(validator.check(&index));
let missing = Document::from_pairs([("$id", string("idx")), ("type", string("key")), ("attributes", list([string("name")]))]).unwrap();
assert!(!validator.check(&missing));
assert_eq!(validator.description(), "Invalid index attribute \"name\" not found");
use utopia_database::validator::index::IndexSupport;
Rust
pub struct IndexSupport

Undocumented.

Also implements Default.