Skip to content

Instantly share code, notes, and snippets.

@guillemcordoba
Created November 12, 2020 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillemcordoba/1b34ee361ed92de81f2c9cda24b88aa9 to your computer and use it in GitHub Desktop.
Save guillemcordoba/1b34ee361ed92de81f2c9cda24b88aa9 to your computer and use it in GitHub Desktop.
#[hdk_entry(id = "profile")]
struct Post(String);
fn query_and_convert_entries<T: HdkEntry>() -> ExternResult<Vec<T>> {
// This function already is implemented for any struct that derives hdk_entry,
// but there is no trait for us to be able to do this generically
let entry_def = T::entry_def();
let filter = ChainQueryFilter::new()
.entry_type(EntryType::App(AppEntryType::new(
entry_def.id,
zome_info!()?.zome_id,
EntryVisibility::Private,
)))
.header_type(HeaderType::Create)
.include_entries(true);
let query_result: ElementVec = query!(filter)?;
Ok(query_result.0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment