use idb::builder::IndexBuilder;
use crate::KeyPath;
pub struct Index {
pub(crate) builder: IndexBuilder,
}
impl Index {
pub fn new(name: &str, key_path: &str) -> Self {
Self {
builder: IndexBuilder::new(name.to_owned(), KeyPath::new_single(key_path)),
}
}
pub fn new_array<'a>(name: &str, key_path_array: impl IntoIterator<Item = &'a str>) -> Self {
Self {
builder: IndexBuilder::new(name.to_owned(), KeyPath::new_array(key_path_array)),
}
}
pub fn unique(mut self, unique: bool) -> Self {
self.builder = self.builder.unique(unique);
self
}
pub fn multi_entry(mut self, multi_entry: bool) -> Self {
self.builder = self.builder.multi_entry(multi_entry);
self
}
}