knex: what is the appropriate way to create an array from results?
问题 I have an endpoint that joins the user and user_emails table as a one-to-many relationship (postgresql). It look as follows. router.get('/', function (req, res, next) { db.select('users.id', 'users.name', 'user_emails.address') .from('users') .leftJoin('user_emails', 'users.id', 'user_emails.user_id') .then(users => res.status(200).json(users)) .catch(next) // go to error handler }); However, this will return a new document for each email address. What I want is an array of documents that