graph-store: add shallow-children scry

This commit is contained in:
Liam Fitzgerald 2021-04-23 11:16:44 +10:00
parent 64db58fa6f
commit 3f7d08285e
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 28 additions and 0 deletions

View File

@ -748,6 +748,26 @@
|= [=atom =node:store]
^- [index:store node:store]
[(snoc parent atom) node]
::
[%x %shallow-children @ @ *]
=/ newest ?=(%newest i.t.path)
=/ =ship (slav %p i.t.t.path)
=/ =term i.t.t.t.path
=/ =index:store
(turn t.t.t.t.path (cury slav %ud))
=/ children
(get-node-children ship term index)
?~ children [~ ~]
:- ~ :- ~ :- %graph-update-1
!> ^- update:store
:+ now.bowl %add-nodes
:- [ship term]
%- ~(gas by *(map index:store node:store))
%+ turn (tap:orm u.children)
|= [=atom =node:store]
^- [index:store node:store]
:- index.post.node
node(children [%empty ~])
::
[%x ?(%newest %oldest) @ @ @ *]
=/ newest ?=(%newest i.t.path)

View File

@ -349,6 +349,14 @@ export default class GraphApi extends BaseApi<StoreState> {
this.store.handleEvent({ data });
}
async getShallowChildren(ship: string, name: string, index = '') {
const idx = index.split('/').map(decToUd).join('/');
const data = await this.scry<any>('graph-store',
`/shallow-children/${ship}/${name}${idx}`
)
this.store.handleEvent({ data });
}
getGraphSubset(ship: string, resource: string, start: string, end: string) {
return this.scry<any>(
'graph-store',