use idb::builder::ObjectStoreBuilder;
use crate::{Index, KeyPath};
pub struct ObjectStore {
pub(crate) builder: ObjectStoreBuilder,
}
impl ObjectStore {
pub fn new(name: &str) -> Self {
Self {
builder: ObjectStoreBuilder::new(name),
}
}
pub fn key_path(mut self, key_path: &str) -> Self {
self.builder = self.builder.key_path(Some(KeyPath::new_single(key_path)));
self
}
pub fn key_path_array<'a>(mut self, key_path_array: impl IntoIterator<Item = &'a str>) -> Self {
self.builder = self
.builder
.key_path(Some(KeyPath::new_array(key_path_array)));
self
}
pub fn auto_increment(mut self, auto_increment: bool) -> Self {
self.builder = self.builder.auto_increment(auto_increment);
self
}
pub fn add_index(mut self, index: Index) -> Self {
self.builder = self.builder.add_index(index.builder);
self
}
}