UNPKG

sharyn

Version:

Combines all the other packages under one.

14 lines (10 loc) 364 B
// @flow import knex from './knex' const createQuery = (tableName: string) => (userId?: string, trx?: Function) => { if (typeof tableName !== 'string') { throw Error('tableName must be a string') } const table = trx ? trx(tableName) : knex(tableName) return userId ? table.where(`${tableName}.userId`, userId) : table } module.exports = createQuery