-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
There's a lot of code being copied over to idm
from echo that is useful in both codebases (internal service modules, utility functions, etc). We'll move these into a standalone lg-toolbox
module that will be published to npm (scoped to @LearnersGuild) and used in multiple codebases.
v1.0 spec:
- services
- dataService
- crmService
- jobService (merged w/ queueService)
Usage:
// in foo.js
import {dataService} from 'lg-toolbox'
async function doAThing() {
const rethinkdb = { // object w/ connection props OR an existing `r` client
servers,
silent,
max,
buffer
}
const options = {
models, // path to directory or array
queries, // path to directory or array
}
const ds = dataService(rethinkdb, options)
const {r, MyModel, getAThing} from ds
const things = await CoolModel.filter(row => {
return r.and(
row('blah').eq(1),
row('blergh').eq(5)
)
})
await getAThing()
}
Object exported by dataService()
:
{
r,
...all Thinky models,
...all query functions,
}