LearnersGuild / echo

learning management system
MIT License
3 stars 31 forks source link

Move shared services code to lg-toolbox #1076

Open heyheyjp opened 7 years ago

heyheyjp commented 7 years ago

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:


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,
}
jaredatron commented 6 years ago

@AbrahamFergie you know what the status of this task is?

heyheyjp commented 6 years ago

The first part is awaiting review. I'll move to In Review and redefine the scope.

jaredatron commented 6 years ago

youre the best around