All blocks
Platform
Read sets
One `stable` function per `defineReadSet` in `readSets`, so `db.$many(readSet, params)` is a single GET.
npx better-supabase sql add read-setsimport { defineConfig } from "better-supabase/config";
export default defineConfig({
sql: {
modules: {
// Modes: "managed". The default is "managed".
"read-sets": { mode: "managed" },
},
},
});npx better-supabase sql add read-sets writes these files into your declarative schema with the default layout. See SQL modules for the migration step and the layout options.
supabase/schemas/900_better_supabase_14_read_sets.sqlschema21 linessupabase/better-supabase-data/900_better_supabase_14_read_sets.sqldata12 lines
supabase/schemas/900_better_supabase_14_read_sets.sql
-- better-supabase module: read-sets -- @bs-module read-sets@1 managed -- One `stable` function per `defineReadSet` in `readSets`, so `db.$many(readSet, params)` is a single GET. -- Managed by `better-supabase sql add`; re-running it overwrites this file. -- Change it through `sql.modules` in better-supabase.config.ts and the module's SQL hooks. -- Functions for the read sets in `readSets` (better-supabase.config.ts); `gen` and `sql sync` rewrite them. -- They are security invoker: RLS decides what each caller reads, as for any other query. create schema if not exists better_supabase; create table if not exists better_supabase.modules ( name text primary key, version integer not null, mode text not null, installed_at timestamptz not null default now(), updated_at timestamptz not null default now() ); alter table better_supabase.modules enable row level security; revoke all on better_supabase.modules from anon, authenticated; grant select on better_supabase.modules to service_role;
supabase/better-supabase-data/900_better_supabase_14_read_sets.sql
-- better-supabase module: read-sets
-- @bs-module-data read-sets
-- Rows and settings a schema diff doesn't capture. Run `better-supabase sql data`
-- after the schema migration to put them in a migration.
-- Managed by `better-supabase sql add`; re-running it overwrites this file.
-- Change it through `sql.modules` in better-supabase.config.ts and the module's SQL hooks.
insert into better_supabase.modules (name, version, mode)
values ('read-sets', 1, 'managed')
on conflict (name) do update
set version = excluded.version, mode = excluded.mode, updated_at = now();
This block is SQL only: call its functions from your policies, RPCs and the other modules.
This module writes no outbox events.