urbit/pkg/arvo/lib/metadata.hoon

70 lines
1.7 KiB
Plaintext
Raw Normal View History

:: metadata: helpers for getting data from the metadata-store
::
2021-01-28 09:13:57 +03:00
/- store=metadata-store
/+ resource
::
|_ =bowl:gall
++ app-paths-from-group
2021-01-28 09:13:57 +03:00
|= [=app-name:store group=resource]
2021-01-12 07:26:19 +03:00
^- (list resource)
%+ murn
%~ tap in
2021-01-12 07:26:19 +03:00
=- (~(gut by -) group ~)
2021-01-28 09:13:57 +03:00
.^ (jug resource md-resource:store)
%gy
(scot %p our.bowl)
%metadata-store
(scot %da now.bowl)
/group-indices
==
2021-01-28 09:13:57 +03:00
|= =md-resource:store
2021-01-12 07:26:19 +03:00
^- (unit resource)
?. =(app-name.md-resource app-name) ~
2021-01-12 07:26:19 +03:00
`resource.md-resource
::
++ app-metadata-for-group
2021-01-28 09:13:57 +03:00
|= [group=resource =app-name:store]
=/ =associations:store
(metadata-for-group group)
2021-01-28 09:13:57 +03:00
%- ~(gas by *associations:store)
%+ skim ~(tap by associations)
2021-01-28 09:13:57 +03:00
|= [=md-resource:store association:store]
=(app-name app-name.md-resource)
::
2021-01-13 07:50:37 +03:00
++ metadata-for-group
|= group=resource
2021-01-28 09:13:57 +03:00
.^ associations:store
2021-01-13 07:50:37 +03:00
%gx (scot %p our.bowl) %metadata-store (scot %da now.bowl)
%group (snoc (en-path:resource group) %noun)
2021-01-13 07:50:37 +03:00
==
::
++ md-resources-from-group
|= group=resource
=- (~(get ju -) group)
2021-01-28 09:13:57 +03:00
.^ (jug resource md-resource:store)
2021-01-13 07:50:37 +03:00
%gy
(scot %p our.bowl)
%metadata-store
(scot %da now.bowl)
/group-indices
==
::
++ peek-association
|= [app-name=term rid=resource]
2021-01-28 09:13:57 +03:00
.^ (unit association:store)
2020-10-22 04:29:35 +03:00
%gx (scot %p our.bowl) %metadata-store (scot %da now.bowl)
%metadata app-name (snoc (en-path:resource rid) %noun)
2020-10-22 04:29:35 +03:00
==
::
2021-01-28 09:13:57 +03:00
++ peek-metadatum
|= =md-resource:store
%+ bind (peek-association md-resource)
2021-01-28 09:13:57 +03:00
|=(association:store metadatum)
2020-10-22 04:29:35 +03:00
::
++ peek-group
2021-01-28 09:13:57 +03:00
|= =md-resource:store
^- (unit resource)
%+ bind (peek-association md-resource)
2021-01-28 09:13:57 +03:00
|=(association:store group)
--