1 | const knex = require('./knex')
|
2 |
|
3 | module.exports = tableName => (userId, trx) => {
|
4 | if (typeof tableName !== 'string') {
|
5 | throw Error('tableName must be a string')
|
6 | }
|
7 | const table = trx ? trx(tableName) : knex(tableName)
|
8 | return userId ? table.where(`${tableName}.userId`, userId) : table
|
9 | }
|