Skip to content

Commit

Permalink
Merge pull request #155 from holochain/refactor-get-links
Browse files Browse the repository at this point in the history
Refactor get links
  • Loading branch information
guillemcordoba authored and ThetaSinner committed Nov 28, 2023
1 parent 4c97355 commit 230725d
Show file tree
Hide file tree
Showing 37 changed files with 841 additions and 259 deletions.
64 changes: 32 additions & 32 deletions run_test.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#!/usr/bin/env bash
set -e

rm -rf /tmp/hello-world
cd /tmp

hc-scaffold example hello-world
cd hello-world

nix develop --command bash -c "
set -e
npm i
npm t
"

rm -rf /tmp/forum-svelte

cd /tmp
Expand All @@ -27,18 +15,18 @@ hc-scaffold dna forum
hc-scaffold zome posts --integrity dnas/forum/zomes/integrity/ --coordinator dnas/forum/zomes/coordinator/
hc-scaffold entry-type post --reference-entry-hash false --crud crud --link-from-original-to-each-update true --fields title:String:TextField,content:String:TextArea
hc-scaffold entry-type comment --reference-entry-hash false --crud crud --link-from-original-to-each-update false --fields post_hash:ActionHash::Post
hc-scaffold entry-type likes --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Likes,string_list:Vec\<String\>
hc-scaffold entry-type like --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Like,string_list:Vec\<String\>
hc-scaffold entry-type certificate --reference-entry-hash true --crud cr --fields post_hash:ActionHash::Post,agent:AgentPubKey::certified,certifications_hashes:Vec\<EntryHash\>::Certificate,certificate_type:Enum::CertificateType:TypeOne.TypeTwo,dna_hash:DnaHash

hc-scaffold collection global all_posts post
hc-scaffold collection by-author posts_by_author post
hc-scaffold collection global all_posts_entry_hash post:EntryHash
hc-scaffold collection global all_likes likes
hc-scaffold collection global all_likes like
hc-scaffold collection by-author posts_by_author_entry_hash post:EntryHash

hc-scaffold link-type post likes --delete true --bidireccional false
hc-scaffold link-type comment likes:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash likes --delete false --bidireccional false
hc-scaffold link-type post like --delete true --bidireccional false
hc-scaffold link-type comment like:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash like --delete false --bidireccional false
hc-scaffold link-type agent:creator post:EntryHash --delete false --bidireccional true


Expand All @@ -60,18 +48,18 @@ hc-scaffold dna forum
hc-scaffold zome posts --integrity dnas/forum/zomes/integrity/ --coordinator dnas/forum/zomes/coordinator/
hc-scaffold entry-type post --reference-entry-hash false --crud crud --link-from-original-to-each-update true --fields title:String:TextField,content:String:TextArea
hc-scaffold entry-type comment --reference-entry-hash false --crud crud --link-from-original-to-each-update false --fields post_hash:ActionHash::Post
hc-scaffold entry-type likes --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Likes,string_list:Vec\<String\>
hc-scaffold entry-type like --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Like,string_list:Vec\<String\>
hc-scaffold entry-type certificate --reference-entry-hash true --crud cr --fields post_hash:ActionHash::Post,agent:AgentPubKey::certified,certifications_hashes:Vec\<EntryHash\>::Certificate,certificate_type:Enum::CertificateType:TypeOne.TypeTwo,dna_hash:DnaHash

hc-scaffold collection global all_posts post
hc-scaffold collection by-author posts_by_author post
hc-scaffold collection global all_likes likes
hc-scaffold collection global all_likes like
hc-scaffold collection global all_posts_entry_hash post:EntryHash
hc-scaffold collection by-author posts_by_author_entry_hash post:EntryHash

hc-scaffold link-type post likes --delete true --bidireccional false
hc-scaffold link-type comment likes:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash likes --delete false --bidireccional false
hc-scaffold link-type post like --delete true --bidireccional false
hc-scaffold link-type comment like:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash like --delete false --bidireccional false
hc-scaffold link-type agent:creator post:EntryHash --delete false --bidireccional true

nix develop --command bash -c "
Expand All @@ -92,18 +80,18 @@ hc-scaffold dna forum
hc-scaffold zome posts --integrity dnas/forum/zomes/integrity/ --coordinator dnas/forum/zomes/coordinator/
hc-scaffold entry-type post --reference-entry-hash false --crud crud --link-from-original-to-each-update true --fields title:String:TextField,content:String:TextArea
hc-scaffold entry-type comment --reference-entry-hash false --crud crud --link-from-original-to-each-update false --fields post_hash:ActionHash::Post
hc-scaffold entry-type likes --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Likes,string_list:Vec\<String\>
hc-scaffold entry-type like --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Like,string_list:Vec\<String\>
hc-scaffold entry-type certificate --reference-entry-hash true --crud cr --fields post_hash:ActionHash::Post,agent:AgentPubKey::certified,certifications_hashes:Vec\<EntryHash\>::Certificate,certificate_type:Enum::CertificateType:TypeOne.TypeTwo,dna_hash:DnaHash

hc-scaffold collection global all_posts post
hc-scaffold collection by-author posts_by_author post
hc-scaffold collection global all_posts_entry_hash post:EntryHash
hc-scaffold collection by-author posts_by_author_entry_hash post:EntryHash
hc-scaffold collection global all_likes likes
hc-scaffold collection global all_likes like

hc-scaffold link-type post likes --delete true --bidireccional false
hc-scaffold link-type comment likes:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash likes --delete false --bidireccional false
hc-scaffold link-type post like --delete true --bidireccional false
hc-scaffold link-type comment like:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash like --delete false --bidireccional false
hc-scaffold link-type agent:creator post:EntryHash --delete false --bidireccional true

nix develop --command bash -c "
Expand All @@ -127,18 +115,18 @@ hc-scaffold dna forum
hc-scaffold zome posts --integrity dnas/forum/zomes/integrity/ --coordinator dnas/forum/zomes/coordinator/
hc-scaffold entry-type post --reference-entry-hash false --crud crud --link-from-original-to-each-update true --fields title:String:TextField,content:String:TextArea
hc-scaffold entry-type comment --reference-entry-hash false --crud crud --link-from-original-to-each-update false --fields post_hash:ActionHash::Post
hc-scaffold entry-type likes --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Likes,string_list:Vec\<String\>
hc-scaffold entry-type like --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Like,string_list:Vec\<String\>
hc-scaffold entry-type certificate --reference-entry-hash true --crud cr --fields post_hash:ActionHash::Post,agent:AgentPubKey::certified,certifications_hashes:Vec\<EntryHash\>::Certificate,certificate_type:Enum::CertificateType:TypeOne.TypeTwo,dna_hash:DnaHash

hc-scaffold collection global all_posts post
hc-scaffold collection by-author posts_by_author post
hc-scaffold collection global all_posts_entry_hash post:EntryHash
hc-scaffold collection global all_likes likes
hc-scaffold collection global all_likes like
hc-scaffold collection by-author posts_by_author_entry_hash post:EntryHash

hc-scaffold link-type post likes --delete true --bidireccional false
hc-scaffold link-type comment likes:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash likes --delete false --bidireccional false
hc-scaffold link-type post like --delete true --bidireccional false
hc-scaffold link-type comment like:EntryHash --delete true --bidireccional true
hc-scaffold link-type certificate:EntryHash like --delete false --bidireccional false
hc-scaffold link-type agent:creator post:EntryHash --delete false --bidireccional true


Expand All @@ -148,3 +136,15 @@ npm i
npm t
npm run package
"

rm -rf /tmp/hello-world
cd /tmp

hc-scaffold example hello-world
cd hello-world

nix develop --command bash -c "
set -e
npm i
npm t
"
5 changes: 3 additions & 2 deletions src/scaffold/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ pub fn scaffold_collection(
&link_type_name,
&None,
&Some(Referenceable::EntryType(entry_type.clone())),
false,
true,
&PathBuf::from(format!("{}.rs", entry_type.entry_type.to_case(Case::Snake))),
)?;

let (dna_file_tree, coordinator_zome) = add_collection_to_coordinators(
let (dna_file_tree, coordinator_zome, deletable) = add_collection_to_coordinators(
zome_file_tree,
collection_name,
&link_type_name,
Expand All @@ -139,5 +139,6 @@ pub fn scaffold_collection(
&collection_type,
collection_name,
&entry_type,
deletable,
)
}
Loading

0 comments on commit 230725d

Please sign in to comment.