question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

find total is always zero when raw is false

See original GitHub issue

Steps to reproduce

I have a 3 models. Product, Shop and Branch.

  • A product only belongs to a shop.
  • A shop has many branches.

I am trying to add this in the find before hook

const sequelize = hook.app.get('sequelizeClient'); hook.params.sequelize = { raw: false, include: [ sequelize.models.shops, { model: sequelize.models['branch-products'], include: [{ model: sequelize.models.branches}] } ] };

Actual behavior

When I add the raw: false, the total is always 0. Also, when I add where in the query. It gives repeated objects.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dafflcommented, Jun 26, 2017

I added the hook by default to a generated Sequelize model in https://github.com/feathersjs/generator-feathers/pull/238

0reactions
adrianolskcommented, Jun 25, 2017

I have the exact same problem, I use raw=false because I want to retrieve associations and it gives me a object with the properties from the other model. If I use raw true it would return ugly data like invoice.customer.name that I can only access client site by use the property as a index invoice['customer.name'] I end up let raw=true and creating a after hook to loop through the data and assign the customer.name to a property customer_name so I can use invoice.customer_name. the workaround that @YeFFreY gave made it work as I want to (Thanks).

Read more comments on GitHub >

github_iconTop Results From Across the Web

I don't understand the why is sum = 0? - Stack Overflow
The method needs to return a boolean. Check that number is > 0, if it is not return false. Write a second method...
Read more >
The Normal Distribution and Z Scores - Department of Sociology
Z scores, which are sometimes called standard scores, represent the number of standard deviations a given raw score is above or below the...
Read more >
Excel FILTER function with formula examples - Ablebits
Since multiplying by zero always gives zero, only the items for which all the criteria are TRUE get into the resulting array, ...
Read more >
Excel VLOOKUP Function Examples and Troubleshoot ...
True: VLOOKUP function returns product price; False: return 0 (zero). In the screen shot below, the correct price was returned: Lamp product was ......
Read more >
4.4.3 Calculating the mode - Statistique Canada
Therefore, the median is equal to 1. Once the data has been summarized in a frequency table, you can see that the mode...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found