fed-sx-m1: Step 4b-proj — 7 bootstrap projections + manifest update + 9 new parse tests (31 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
This commit is contained in:
22
next/genesis/projections/by-object.sx
Normal file
22
next/genesis/projections/by-object.sx
Normal file
@@ -0,0 +1,22 @@
|
||||
;; next/genesis/projections/by-object.sx
|
||||
;;
|
||||
;; Index of activities that reference each :object CID. Maps
|
||||
;; object-CID to the list of activity CIDs that target it
|
||||
;; (Update / Delete / Announce / etc.). Used for "show me
|
||||
;; everything that happened to X" queries.
|
||||
|
||||
(DefineProjection
|
||||
:name "by-object"
|
||||
:doc "Object CID -> list of activity CIDs that target it."
|
||||
:initial-state {}
|
||||
:fold (fn
|
||||
(state act)
|
||||
(let
|
||||
((obj-cid (-> act :object)) (cid (-> act :cid)))
|
||||
(if
|
||||
(string? obj-cid)
|
||||
(assoc
|
||||
state
|
||||
obj-cid
|
||||
(append (or (get state obj-cid) (list)) (list cid)))
|
||||
state))))
|
||||
Reference in New Issue
Block a user