Skip to content

Instantly share code, notes, and snippets.

@eric-burel
Created June 21, 2018 15:53
Show Gist options
  • Save eric-burel/c6f2db6901a7dc12ecbd1fa26a30bdfc to your computer and use it in GitHub Desktop.
Save eric-burel/c6f2db6901a7dc12ecbd1fa26a30bdfc to your computer and use it in GitHub Desktop.
class MyService {
constructor(options) {
// options must contain the knexClient
// (simply pass it when initializing the service)
this.options = options || {};
}
async find(params){
const { db } = this.options
const q = db.raw(`SELECT * FROM TABLE`)
const res = await q
return res
}
// ...other CRUD methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment