Holochain CRUD Library (CAPS pattern)
A CRUD library for Holochain zomes that implement the CAPS pattern (Chained, Action, Permalink, State-based)
Holochain Version Map
For information on which versions of this package work for each Holochain release, see docs/Holochain_Version_Map.md
Overview
Install
Example of adding to Cargo.toml
[]
= "0.1.0"
Example of common imports
use ;
Basic Usage
CRUD Operations
These imports and structs are assumed for all examples
use *;
use ;
entry_model!;
Create an entry
Example
let input = PostEntry ;
let post_entity = create_entity?;
[Read] Get an entry
Example
let post_entity = get_entity?;
Update an entry
Example
let post_entity = update_entity?;
Delete an entry
Example
?;
Example of CRUD for relationships
Create a 1-to-many relationship for post entries to have comment entries.
The following examples use this additional struct
Add CommentEntry to EntryTypes enum
#[hdk_entry_defs]
#[unit_enum(UnitEntryTypes)]
pub enum EntryTypes {
#[entry_def]
Post(PostEntry),
+ #[entry_def]
+ Comment(CommentEntry),
}
+entry_model!( EntryTypes::Comment( CommentEntry ) );
Create a CommentEntry and link it to the PostEntry
let input = CommentEntry ;
let comment_entity = create_entity?;
comment_entity.link_from?;
Get a Collection for a specific base and tag
let collection : = get_entities?;
API Reference
Contributing
See CONTRIBUTING.md