Retrieving Complete Binders list, including nested Binders and Sections


So I'm trying to get the complete list of all binders and nested binders/sections. Is there is easy way to get this using VQL?


SELECT id, name__v, description__v, title__v,
(SELECT id, parent_node_id__sys, name__v, parent_node__sysr.type__sys, type__sys, document__sysr.id, document__sysr.name__v, document__sysr.binder__v, parent_binder_id__sys, content_id__sys
FROM binder_nodes__sysr
FROM binders


I'm using this right now, but I can't really figure out how the binders relate to each other as there don't seem to be an obvious parent_id or something.

I'm trying to display a checkbox tree of the complete binder/section hierarchy structure.


I've also tried to do this without VQL using the /api/{version}/objects/documents API to retrieve the first level of binders, according to the documentation "Note that nested binders (a binder contained within another binder) are not retrieved." nested binders aren't retrieved but some reason I'm getting all binders in my vault.


Is it possible to only get the first level of binders? I'm trying to get the first level then make subsequent calls for retrieving the child nodes using /api/{version}/objects/binders/{binder_id}


  • Avatar
    Mark Arnold Official comment

    In the query you provided, you can find the child binders by inspecting the subquery for document__sysr.binder__v=true. The document__sysr.id will be the child binder id.

    There is not a way to query a distinct list of root binders with no parent binders, but you can meet the use case by using your query and keeping a running list of parent binders from the main query (id) and also keep a running list of child binders from the subquery (document__sysr.id where document__sysr.binder__v=true).

    You would then remove the child binder ids from the list of parent binder ids, and the remaining ids are your root binders with no parents.

  • Avatar
    Raphael Goubet

    I'm also looking forward for an answer to this. So far, it seems that the only way is to create a recursive function to walk down the binder, but I've also been hoping for a simpler solution to get everything at once.

Please sign in to leave a comment.