find total is always zero when raw is false
See original GitHub issueSteps 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:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added the hook by default to a generated Sequelize model in https://github.com/feathersjs/generator-feathers/pull/238
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 likeinvoice.customer.name
that I can only access client site by use the property as a indexinvoice['customer.name']
I end up let raw=true and creating a after hook to loop through the data and assign thecustomer.name
to a propertycustomer_name
so I can useinvoice.customer_name
. the workaround that @YeFFreY gave made it work as I want to (Thanks).