You would add the metadata containing clojure.datafy/nav
as the key (and your nav
function as the value) to the collection that would be passed to nav
, i.e., the nested maps.
It's worth thinking about the full context tho' (for REBL and other tools that use datafy
and nav
): you start out with "stuff" that is first datafy
'd by those tools to produce "pure data" that can be navigated via get
etc and also via nav
.
So you go from "stuff" -> datafy
-> "pure data" (plus nav
metadata).
Then from "pure data" -> get
-> "new pure data", or from "pure data" -> nav
-> "new stuff corresponding to new pure data".
So you might want to start out with your map supporting datafy
metadata so that when REBL etc datafies it, the result is navigable -- and could be augmented with additional keys and/or metadata as part of the datafication for display in REBL etc.
If you start with pure data (with nav
metadata), calling datafy
on it should be an identity function so you could just add nav
metadata to the original map. I personally think it's better to start with datafy
metadata (and have the implementation add the nav
metadata) so that the stuff -> datafy
-> data -> nav
-> new-stuff pattern is more explicit. That's the approach I took in clojure.java.jdbc
and next.jdbc
-- and I blogged about datafy
/nav
in December 2018.