berlin / haushaltsdaten

Data visualization of Berlin's public expenditures
https://haushaltsdaten.odis-berlin.de
MIT License
8 stars 3 forks source link

Show total result size instead of 500+ in full text search page #70

Closed vogelino closed 1 year ago

vogelino commented 2 years ago

image

vogelino commented 2 years ago
  1. Make call to the API to get the total count by using count options
  2. render it to the right place

Questions: The call is a remote procedure call. The RPC should return the total count of rows. -> We can use the count: exact param of the SDK rpc function. See: https://supabase.com/docs/reference/javascript/next/rpc#with-count-option

ff6347 commented 2 years ago

Example request done with Deno:

import { createClient } from "https://esm.sh/@supabase/supabase-js@1.35.3";

const supabase = createClient(
    "<SUPABASE URL>",
    "<ANON TOKEN>",
);

const { data, error, count } = await supabase.rpc(
    "ftc",
    { search: "mitte" },
    { count: "exact" },
);

if (error) {
    console.error(error);
    throw error;
}
console.log(count);

We make the request here