I’m trying to make my knex code simpler by removing knex.from('table')
or knex('table')
from my queries to something like table.where(...).select()
and by doing this I make sure I’m not pointing to a wrong table or a typo.
And part of my solution is adding some code like this on my db.js file:
export const users = knex('users');
export const roles = knex('roles');
and then importing on any controller file like this example:
import { users } from "../lib/db.js";
const getUsers = async () => {
return users.select();
}
But in older projects I had the issue that if I make multiple calls with the same query builder it won’t make new query but instead adding logic to the first query.
Is there a way of doing this?