qryq
is a NodeJs library that allows one to express a series of queries and define dependencies between them either in parallel, in sequence, or in a directed acyclic graph.
A directed graph with no directed cycles.
That is, it is formed by a collection of vertices and directed edges, each edge connecting one vertex to another, such that there is no way to start at some vertex v and follow a sequence of edges that eventually loops back to v again
POST /api/
[
[ 'deleteMessages', {
idList: [ 'msg1' ]
}],
[ 'getMailboxMessageList', {
mailboxName: 'Inbox',
position: 0,
limit: 30,
sort: 'date descending'
}]
]
[
{id: "q1", api: "add", qry:{a:1, b:9}},
{id: "q2", api: "add", qry:{a:99, b:1}},
{id: "q3", api: "multiply", qry:{a: "#{q1}", b: "#{q2}"}},
{id: "q4", api: "multiply", qry:{a: "#{q3}", b:5}}
]
`q2` --> add(99, 1) --> 100
`q1` --> add(1, 9) --> 10
`q3` --> multiply(`q1`, `q2`) --> multiply(10, 100) --> 1000
`q4` --> multiply(`q3`, 5) --> multiply(1000, 5) --> 5000
q1
and q2
may execute in any order,q3
may only execute after both q1
and q2
,q4
executes last.qryq
Let's look at some!
What is it like to write the same thing using async vs. using qryq?
(also callbacks, and promises)
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together.
-- Doug McIlroy, invented pipes in UNIX
`#{previousQry}.flights.length`
qry
references results of another qry
in the same qryq
Q
spaghetti in walkrenodeunit
depends
if not provided using two passes when parsing each qry
qryq
qryq