use std::ops::Deref;
use idb::builder::ObjectStoreBuilder;
use serde::{de::DeserializeOwned, Serialize};
use crate::{error::Error, object_store::ObjectStore, transaction::Transaction};
pub trait Model: Serialize + DeserializeOwned {
const NAME: &'static str;
type Key: Serialize + DeserializeOwned;
type Add: Serialize;
type ObjectStore<'t>: Deref<Target = ObjectStore<'t, Self>> + From<ObjectStore<'t, Self>>;
fn with_transaction(transaction: &Transaction) -> Result<Self::ObjectStore<'_>, Error> {
transaction.object_store::<Self>().map(Into::into)
}
#[doc(hidden)]
fn object_store_builder() -> ObjectStoreBuilder;
}