how can i add others attributes with distinct
See original GitHub issuehi all
i wrote this hook and it works.
const sequelize = require('sequelize');
module.exports = function () {
return async context => {
let query = context.params.query;
if (query.$distinct) {
const field = query.$distinct;
delete context.params.query.$distinct;
context.params.sequelize = {
attributes: [
[sequelize.fn('DISTINCT', sequelize.col('user_id')), 'userId'],
]
};
//console.log( context.params.sequelize);
}
};
};
but i need another fields like id, title and … so i added them:
const sequelize = require('sequelize');
module.exports = function () {
return async context => {
let query = context.params.query;
if (query.$distinct) {
const field = query.$distinct;
delete context.params.query.$distinct;
context.params.sequelize = {
attributes: [
[sequelize.fn('DISTINCT', sequelize.col('user_id')), 'userId'],
'id',
'title'
]
};
//console.log( context.params.sequelize);
}
};
};
but in the second way distinct not working. sorry for my poor english. any help?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
using distinct with all attributes - mysql
We can use * to select all attribute from table ,I am using distinct and my table contain 16 columns, How can I...
Read more >SQL SELECT with DISTINCT on multiple columns
You can use an order by clause in the select statement with distinct on multiple columns. Here is an example: SQL Code: SELECT...
Read more >SQL SELECT DISTINCT Statement
The SELECT DISTINCT statement is used to return only distinct (different) values. Inside a table, a column often contains many duplicate values; and...
Read more >ALL, DISTINCT, DISTINCTROW, TOP Predicates
Syntax ; DISTINCT. Omits records that contain duplicate data in the selected fields. To be included in the results of the query, the...
Read more >Applying Select Distinct to One Column Only
If we were now to add the DISTINCT clause to a query whose field list contains other columns, it does not work because...
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
The stalebot clearly states why this was closed and marked as won’t fix. But I can also give you a little more context as to why it is not a fixable or even answerable issue.
I don’t speak for feathers or the feathers community as a whole, but I can tell you that posting snarky remarks on a half baked issue is not likely to get you the help you want. The OP at least said “hi”, “sorry for my poor english” (which explains the terse request), and then asked for help with “any help?”. What have you added to the conversation?
Now, to answer your question (which you didn’t even ask…just basically said “same here, why the hell isnt this fixed”)…its likely a Sequelize and/or Sequelize and your DB type/version issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn’t anybody available to address the issue at the moment. For other ways to get help see here.