soda-ts
functional SoQL wrapper to interact with Open Data API
branch | coverage | CI |
---|---|---|
staging | ||
master |
install
# for js yarn add ramda rxjs soda-ts# for the adventurous 🤷🏼♂️ yarn add https://github.com/data-depot/soda-ts.git# for ts yarn add -D @types/ramda
use
soda-ts
was designed with composition in mind.
To start of, we need to create a query
.
Dataset src
id must be provided while the
domain defaults to NYC Open Data
createQuery
// to pull from other domains
A raw query
is the most primitive form of query.
To make it more interesting, we need to compose it
with clauses
createRunner$
Now, we can run the query
. We have a Promise
and Observable
wrappers. For simple requests, createRunner
, which is
Promise
based, is quite useful. But we'd recommend
the Observable
api.
pipe createQuery where`something > 12` createRunner$authOpts .subscribe next:, error: ..., complete: ...
autoPaginator$
To grab large paginated datasets, we can take
advantage of query
managers. They handle all aspects of
pagination automagically and uses Subjects
from rxjs
as an eventbus. Combining ramda
and rxjs
composition,
we can write declarative code to handle all the side effects
cleanly.
paginatorSub$.subscribe pipe createQuery where`SOMETHING > 0` createManagerCreatormanagerOpts, autoPaginator$paginatorSub$.subscribe