GithubHelp home page GithubHelp logo

Filtering by totalCount about pg-aggregates HOT 3 CLOSED

graphile avatar graphile commented on August 25, 2024
Filtering by totalCount

from pg-aggregates.

Comments (3)

Claire-Couppie avatar Claire-Couppie commented on August 25, 2024 1

Thank you, actually your answer already helped me solve my issue !

My mistake was using the foreign key from warehouses to company instead of warehouses table primary key in the filter, when trying to match my case to the solution that was suggested in graphile-contrib/postgraphile-plugin-connection-filter#152.

I used the query:

query MyQuery {
  companies(
    orderBy: WAREHOUSES_COUNT_DESC
    filter: {warehouses: {aggregates: {distinctCount: {companyId: {greaterThan: "1"}}}}}
  ) {
    nodes {
      warehouses {
        totalCount
      }
    }
  }
}

Which returned an empty list (but worked as expected with greaterThan: "0", returning all totalCount values > 0) instead of:

query MyQuery {
  companies(
    filter: {warehouses: {aggregates: {distinctCount: {id: {greaterThan: "1"}}}}}
  ) {
    nodes {
      warehouses {
        totalCount
      }
    }
  }
}

I'm closing the issue then, thanks for your help !

from pg-aggregates.

benjie avatar benjie commented on August 25, 2024

Please could you share the query that you attempted with distinctCount - I'd expect a distinctCount over a unique column (such as the primary key) to give the result you're hoping for.

Further, please can you expand on "it worked only for greater than 0" - what were the other cases you tried and what happened in those cases - an error? incorrect results? Please share as much detail as you can.

A rough definition of the relevant tables/columns/constraints in your database would also be helpful.

from pg-aggregates.

benjie avatar benjie commented on August 25, 2024

Thanks for sharing 🙌

from pg-aggregates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.