use super::super::inner::entry;
use crate::handles::{DbRead, DbWrite};
use crate::kind::Dht;
use holo_hash::{AgentPubKey, EntryHash};
use holochain_integrity_types::entry::Entry;
use std::collections::HashMap;
impl DbWrite<Dht> {
pub async fn insert_entry(&self, hash: &EntryHash, entry: &Entry) -> sqlx::Result<()> {
entry::insert_entry(self.pool(), hash, entry).await
}
pub async fn insert_private_entry(
&self,
hash: &EntryHash,
author: &AgentPubKey,
entry: &Entry,
) -> sqlx::Result<()> {
entry::insert_private_entry(self.pool(), hash, author, entry).await
}
}
impl DbRead<Dht> {
pub async fn get_entry(
&self,
hash: EntryHash,
author: Option<&AgentPubKey>,
) -> sqlx::Result<Option<Entry>> {
let mut conn = self.timed_conn().await?;
entry::get_entry(&mut *conn, hash, author).await
}
pub async fn get_entries_by_hashes(
&self,
hashes: &[EntryHash],
author: Option<&AgentPubKey>,
) -> sqlx::Result<HashMap<EntryHash, Entry>> {
let mut conn = self.timed_conn().await?;
entry::get_entries_by_hashes(&mut conn, hashes, author).await
}
}