SupabaseRepository
Defined in: supabase-repository.ts:57
Abstract base class for Supabase-backed repositories.
Extend this class and set tableName to implement a Mantle Repository<T>
backed by a Supabase (PostgreSQL) table via the Supabase JS client.
Example
Section titled “Example”class UserRepository extends SupabaseRepository<User> { readonly tableName = "users";
async findByEmail(email: string): Promise<User | null> { const { data, error } = await this.db.select("*").eq("email", email).maybeSingle(); if (error) throw this.wrapError(error); return data ?? null; }}Type Parameters
Section titled “Type Parameters”T extends Record<string, unknown>
D = Partial<T>
Implements
Section titled “Implements”Repository<T,D>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SupabaseRepository<
T,D>(app):SupabaseRepository<T,D>
Defined in: supabase-repository.ts:89
Parameters
Section titled “Parameters”Returns
Section titled “Returns”SupabaseRepository<T, D>
Properties
Section titled “Properties”
protectedreadonlyapp:MantleApplication
Defined in: supabase-repository.ts:61
client
Section titled “client”
protectedreadonlyclient:SupabaseClient
Defined in: supabase-repository.ts:60
listenToChanges
Section titled “listenToChanges”
readonlylistenToChanges:boolean=false
Defined in: supabase-repository.ts:87
When true, subscribes to Postgres Changes for this table and re-emits
direct DB mutations (PostgREST, migrations, Supabase Studio) as Mantle
service:event emissions on the app event bus. These emissions carry
{ external: true } as their params so consumers can distinguish them
from hook-pipeline events; external UPDATEs always map to "patched".
Default
Section titled “Default”falseprimaryKey
Section titled “primaryKey”
readonlyprimaryKey:string="id"
Defined in: supabase-repository.ts:70
The primary key column name.
Default
Section titled “Default”"id"tableName
Section titled “tableName”
abstractreadonlytableName:string
Defined in: supabase-repository.ts:64
Supabase table name.
timestamps
Section titled “timestamps”
readonlytimestamps:boolean=true
Defined in: supabase-repository.ts:77
When true, save / saveAll / updateById / patchById automatically
write created_at and updated_at ISO-8601 timestamps.
Default
Section titled “Default”trueAccessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get
protecteddb():AnyQuery
Defined in: supabase-repository.ts:153
Returns a query builder scoped to this repository’s table. Useful for writing custom queries in subclasses.
Returns
Section titled “Returns”AnyQuery
Methods
Section titled “Methods”applyParams()
Section titled “applyParams()”
protectedapplyParams(query,params?):AnyQuery
Defined in: supabase-repository.ts:176
Apply QueryParams filters, sorting, and pagination to a query builder.
Subclasses may call this to re-use the standard filter logic in custom queries.
Parameters
Section titled “Parameters”AnyQuery
params?
Section titled “params?”Returns
Section titled “Returns”AnyQuery
count()
Section titled “count()”count(
params?):Promise<number>
Defined in: supabase-repository.ts:477
Parameters
Section titled “Parameters”params?
Section titled “params?”Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”deleteById()
Section titled “deleteById()”deleteById(
id):Promise<T>
Defined in: supabase-repository.ts:456
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<T>
Implementation of
Section titled “Implementation of”describe()
Section titled “describe()”describe():
RepositoryCapabilities
Defined in: supabase-repository.ts:341
Optional capability introspection. All
Returns
Section titled “Returns”Mantlejs
Section titled “Mantlejs”adapters implement it; user repositories may omit it.
Implementation of
Section titled “Implementation of”findAll()
Section titled “findAll()”findAll(
params?):Promise<T[]>
Defined in: supabase-repository.ts:353
Parameters
Section titled “Parameters”params?
Section titled “params?”Returns
Section titled “Returns”Promise<T[]>
Implementation of
Section titled “Implementation of”findById()
Section titled “findById()”findById(
id):Promise<T|null>
Defined in: supabase-repository.ts:369
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<T | null>
Implementation of
Section titled “Implementation of”patchById()
Section titled “patchById()”patchById(
id,data):Promise<T>
Defined in: supabase-repository.ts:432
Parameters
Section titled “Parameters”D
Returns
Section titled “Returns”Promise<T>
Implementation of
Section titled “Implementation of”save()
Section titled “save()”save(
data):Promise<T>
Defined in: supabase-repository.ts:383
Parameters
Section titled “Parameters”D
Returns
Section titled “Returns”Promise<T>
Implementation of
Section titled “Implementation of”saveAll()
Section titled “saveAll()”saveAll(
data):Promise<T[]>
Defined in: supabase-repository.ts:398
Parameters
Section titled “Parameters”D[]
Returns
Section titled “Returns”Promise<T[]>
Implementation of
Section titled “Implementation of”updateById()
Section titled “updateById()”updateById(
id,data):Promise<T>
Defined in: supabase-repository.ts:413
Parameters
Section titled “Parameters”D
Returns
Section titled “Returns”Promise<T>
Implementation of
Section titled “Implementation of”wrapError()
Section titled “wrapError()”
protectedwrapError(err):Error
Defined in: supabase-repository.ts:504
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”Error