Giter Club home page Giter Club logo

Comments (7)

dstpierre avatar dstpierre commented on August 23, 2024 1

ho yep now I get you 👍 , it'd say from the URL. /db/count/ a real URL will look like this:

/db/count/tasks where tasks is the collection name. You grab it via the getURLPath(path, 3) for instance. Do not use the soon deprecated ShiftPath function as of #62

from core.

dstpierre avatar dstpierre commented on August 23, 2024 1

this is how PG wants the field name to be when querying on a field. the data field is a JSONB and the syntax ``data->>'field-name' is the way to target a field name from the JSONB object.

Not sure why you're getting an error though. Technically you would not need this for the Count though, you'd use the same function to build the filters as the QueryDocument or the UpdateMany functions for instance.

Also the data field is only present on user's defined collection, not built-in SB collection, for example the sb_accounts has no data JSONB field, but is a real PG table without JSON data.

from core.

VladPetriv avatar VladPetriv commented on August 23, 2024 1

@dstpierre Can you review my PR?

from core.

VladPetriv avatar VladPetriv commented on August 23, 2024

How we'll get column name? From url like /db/count/{{column_name}} or from where?🤔

from core.

dstpierre avatar dstpierre commented on August 23, 2024

@VladPetriv there's no need to column_name. It's a count for the entire collection optionally based on filters (like the Query and the UpdateMany).

It counts the numbers of rows matching the filters, or without filters. It's an HTTP POST that's made to /db/count which accept a similar filters as the query function or no filter.

Hope that helps clarify. Let me know.

from core.

VladPetriv avatar VladPetriv commented on August 23, 2024

Got it. But from where you want to get collection name?🤔

from core.

VladPetriv avatar VladPetriv commented on August 23, 2024

Got it thanks

But also have a question about this:

field = fmt.Sprintf(`data->>'%s'`, field)

What does data->> mean?🤔 I never met it before.
Because in my case PosgreSQL returns this error pq: column "data" does not exist
If I remove this data->> it works fine🤔

PosgreSQL version
psql (PostgreSQL) 14.5 (Ubuntu 14.5-1.pgdg22.04+1)

from core.

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.