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.

how can i add others attributes with distinct

See original GitHub issue

hi 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DaddyWarbuckscommented, Jul 8, 2021

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.

  • There are no versions of feathers-sequelize or Sequelize specified. How can someone who wants to help know how to help if we don’t know what versions you are on? Creating a new issue in this repo has an issue template that asks for these.
  • There is no database type specified. Postgres? MySQL? SQLite?
  • What method are you trying to use? Get? Find? Update? Patch? Remove?
  • The example code provided has a number of bugs. Given that code, how do we know the OP or you have not introduced some other bug that is causing this? The given code example itself won’t work so how can we help fix something that does not even work in the first place?
  • Did you read the README? Specifically this part: https://github.com/feathersjs-ecosystem/feathers-sequelize#testing-sequelize-queries-in-isolation . Its unlikely that this is a feathers-sequelize issue at all because feathers-sequelize is just a light wrapper around Sequelize. That’s the main reason this was probably never answered and eventually automatically marked as stale and wontfix.

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.

1reaction
stale[bot]commented, Aug 24, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

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