We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing the knex query (via createQuery()) in a before hook returns an error when there are 0 rows in my postgres DB:
TypeError: Cannot read property 'total' of undefined at countQuery.then.count (/path/to/node_modules/feathers-knex/lib/index.js:184:48)
As soon as there are rows, everything works fine.
My before hook that does a count / join:
const { mapKeys } = require('lodash'); module.exports = (options = {}) => { // eslint-disable-line no-unused-vars return async context => { // PREVENT: "column reference "[column name]" is ambiguous" const sort = mapKeys(context.params.query.$sort, (order, field) => `plannings.${field}`); context.params.query.$sort = sort; const query = context.service.createQuery({ query: context.params.query }); query .count('plannings.id as planninRuleCount') .leftJoin('planningRules as plr', 'plr.planningId', 'plannings.id') .groupBy('plannings.id'); if (context.id) // Scope the query if it's a single GET call query.where('plannings.id', context.id); context.params.knex = query; return context; }; };
The text was updated successfully, but these errors were encountered:
Fix feathersjs-ecosystem#147
070807c
4b09e99
No branches or pull requests
Steps to reproduce
Changing the knex query (via createQuery()) in a before hook returns an error when there are 0 rows in my postgres DB:
As soon as there are rows, everything works fine.
My before hook that does a count / join:
The text was updated successfully, but these errors were encountered: