How to use COUNT option in Supabase (HTTPS node)?

Describe the problem/error/question

I want to use the COUNT option in Supabase to retrieve number of rows instead of row values. E.g. instead of returning “apple”, “banana”, “monkey”, it will return “3” as the output. Current Supabase Node doesn’t support that (correct me if I’m wrong) so I’m using HTTPs node to send a GET request.

My Supabase Messages Table structure
Columns:
user_id
chat_id
message_bot

Goal
GET the count of rows for column message_bot that matches a specific user_id and chat_id.

Reason to get count and not values
My guess here is if I retrieve 1,000 message_bot values instead of just a number like “4”, it will increase the load on the flow and server. So performance wise I’d rather just get the count than values.

Main Problem
Not sure how to translate/apply the JS selector in Supabase Docs and Stackoverflow answer to n8n https node. Like how can I use that “COUNT” option in the HTTPS node or Supabase node (if possible).

Supabase Docs on how to use COUNT option in JS
See parameters, options toggle, count

Stackoverflow guide on how to use COUNT

What is the error message (if any)?

ERROR: Bad request - please check your parameters

“failed to parse filter (exact)” (line 1, column 1)

Please share your workflow

Share the output returned by the last node

Current output is “Apple”, “Banana”, “Monkey” which is the text values of the message_bot but I want the output to be “3”, just the count

Information on your n8n setup

  • **n8n version:**1.1.1
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker

Hi @pooria :wave: Looking at the example in their API docs, I think you should be able to import this cURL request and get what you need:

curl -X GET \
  -H "apikey: YOUR_API_KEY" \
  "https://YOUR_SUPABASE_URL/rest/v1/countries?select=*,count(exact,head=true)"

In short, I think those parameters would look like this in the HTTP Request node:

I don’t have anything in Supabase set up, so I haven’t tested this - could you give this a go and see if that sorts this out? :slight_smile:

Hey @EmeraldHerald,

Thx for the response.

That didn’t work

And one other thing,

I don’t want to “select *”, i want to select message bot.

I also tried select and message_bot,count(exact,head=true) that didn’t work too

So previously I used select as name and value was message_bot.

I simply want to return a count of all message_bot for a specific user_id and chat_id. Showing previous parameters that returns values of message_bots here:

Hi @pooria - I’m unfortunately not too sure then :see_no_evil: You may need to get in touch with Supabase and see if they can help guide you on the API call, and I’d also suggest making a post on our Feature Requests section of our forums to have our product team take a look into adding the count option as natively supported by our node.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.