is there a way I can store a variable in a knex query? Right now I can console.log a query result by doing:
knex.select().table('users').then(function(result) {
result.forEach(function(value) {
console.log(value);
});
});
But I want to store the query result in a variable - something like this:
var query = knex.select().table('users')
so I can pass it onto a template, manipulate it, etc...
One thing I have tried is creating an empty array and pushing each value into the array, but the array returns empty for some reason:
var dataArr = [];
knex.select().table('users').then(function(result) {
result.forEach(function(value) {
dataArr.push(value)
});
});
console.log(dataArr.length) // returns 0