     2dup type-and-name-node [ 2nip ] [ create-node-of-type ] if* ;
 
 : type-and-name-in-context-node ( context type name -- node )
-    [
-        "id" "n" [ 0 column-int ] ,field
-        "nodes n" ,table
-        "n.name = :name" ,condition
-        ":name" ,arg
-        "arcs a" ,table
-        "a.relation = :has_type" ,condition
-        has-type-relation ":has_type" ,arg
-        "a.subject = n.id" ,condition
-        "a.object = :type" ,condition
-        ":type" ,arg
-        "arcs b" ,table
-        "b.subject = a.relation" ,condition
-        "b.relation = :has_context" ,condition
-        has-context-relation ":has_context" ,arg
-        "b.object = :context" ,condition
-        ":context" ,arg
-    ] with-query 1result ;
+    <query>
+    "id" "n" [ 0 column-int ] add-field
+    "nodes n" add-table
+    "n.name = :name" add-condition
+    ":name" add-arg
+    "arcs a" add-table
+    "a.relation = :has_type" add-condition
+    has-type-relation ":has_type" add-arg
+    "a.subject = n.id" add-condition
+    "a.object = :type" add-condition
+    ":type" add-arg
+    "arcs b" add-table
+    "b.subject = a.relation" add-condition
+    "b.relation = :has_context" add-condition
+    has-context-relation ":has_context" add-arg
+    "b.object = :context" add-condition
+    ":context" add-arg
+    get-results 1result ;
+
 
 ! ideas for an api:
 ! this would work something like jquery, where arcs can be selected according

        "select" , dup fields-sql , dup "from" , tables-sql , conditions-sql ,
    ] { } make " " join ;

: prepare-query ( query -- )
    [ query-sql prepare ] keep set-query-statement ;

: bind-query ( query -- )
    dup query-args over query-statement bindings swap set-query-statement ;

: (retrieve) ( statement query -- result )
    query-fields swap [ field-retriever call ] curry each ;

: retrieve ( query -- )
    dup query-statement over [ (retrieve) ] curry sqlite-map
    swap set-query-results ;
   ! dup query-statement over query-retriever sqlite-map swap set-query-results ;

: finalize-query ( query -- )
    query-statement dup sqlite-finalize f swap set-query-statement ;

PRIVATE>
    

    query construct-boa ;

: invalidate-query ( query -- query )
    f >>results ;

: add-field ( field query -- query )
    dup invalidate-query fields>> push ;

: add-table ( table query -- query )
    dup invalidate-query tables>> push ;

: add-condition ( condition query -- query )
    tuck invalidate-query conditions>> push ;

: add-arg ( arg key query -- query )
    [ invalidate-query args>> set-at ] keep ;

<PRIVATE

: field-sql ( field -- sql )
    [ dup table>> % CHAR: . , name>> % ] "" make ;

: fields-sql ( query -- sql )
    fields>> dup length [
        [ field-sql ] map ", " join
    ] [
        drop "*"
    ] if ;

: tables-sql ( query -- sql )
    tables>> ", " join ;

: conditions-sql ( query -- sql )
    conditions>> dup length [
        " and " join "where " swap append
    ] [
        drop ""
