Class Client
public class Client : IPostgrestClient, IGettableHeaders
- Inheritance
-
Client
- Implements
-
IGettableHeaders
- Inherited Members
Constructors
Client(string, ClientOptions?)
Should be the first call to this class to initialize a connection with a Postgrest API Server
public Client(string baseUrl, ClientOptions? options = null)
Parameters
baseUrlstringApi Endpoint (ex: "http://localhost:8000"), no trailing slash required.
optionsClientOptionsOptional client configuration.
Properties
BaseUrl
API Base Url for subsequent calls.
public string BaseUrl { get; }
Property Value
GetHeaders
Function that can be set to return dynamic headers.
Headers specified in the constructor options will ALWAYS take precedence over headers returned by this function.
public Func<Dictionary<string, string>>? GetHeaders { get; set; }
Property Value
Options
The Options Client was initialized with.
public ClientOptions Options { get; }
Property Value
Methods
AddDebugHandler(DebugEventHandler)
Adds a debug handler
[Obsolete("The debug handler is replaced by OpenTelemetry-compatible diagnostics: subscribe to the ActivitySource and Meter named \"Supabase.Postgrest\". This member will be removed in a future major version.")]
public void AddDebugHandler(IPostgrestDebugger.DebugEventHandler handler)
Parameters
handlerIPostgrestDebugger.DebugEventHandler
AddRequestPreparedHandler(OnRequestPreparedEventHandler)
Adds a handler that is called prior to a request being sent.
public void AddRequestPreparedHandler(OnRequestPreparedEventHandler handler)
Parameters
handlerOnRequestPreparedEventHandler
Attach<T>(T)
Attaches this client's context (BaseUrl, RequestClientOptions,
and its headers callback) to a model, so that Update/Delete can be called directly on the
model afterward.
Intended for models that were deserialized by something other than this client's own Table<T>
responses (which already attach this context automatically) - for example, a model deserialized from a
Realtime event.
public T Attach<T>(T model) where T : BaseModel
Parameters
modelTThe model to attach context to. Mutated in place and also returned for chaining.
Returns
- T
The same model instance, for convenience.
Type Parameters
TCustom Model derived from
BaseModel
ClearDebugHandlers()
Clears debug handlers
[Obsolete("The debug handler is replaced by OpenTelemetry-compatible diagnostics: subscribe to the ActivitySource and Meter named \"Supabase.Postgrest\". This member will be removed in a future major version.")]
public void ClearDebugHandlers()
ClearRequestPreparedHandlers()
Clears all OnRequestPreparedEventHandler handlers.
public void ClearRequestPreparedHandlers()
RemoveDebugHandler(DebugEventHandler)
Removes a debug handler
[Obsolete("The debug handler is replaced by OpenTelemetry-compatible diagnostics: subscribe to the ActivitySource and Meter named \"Supabase.Postgrest\". This member will be removed in a future major version.")]
public void RemoveDebugHandler(IPostgrestDebugger.DebugEventHandler handler)
Parameters
handlerIPostgrestDebugger.DebugEventHandler
RemoveRequestPreparedHandler(OnRequestPreparedEventHandler)
Removes an OnRequestPreparedEventHandler handler.
public void RemoveRequestPreparedHandler(OnRequestPreparedEventHandler handler)
Parameters
handlerOnRequestPreparedEventHandler
Rpc(string, object?)
Perform a stored procedure call.
public Task<BaseResponse> Rpc(string procedureName, object? parameters = null)
Parameters
procedureNamestringThe function name to call
parametersobjectThe parameters to pass to the function call
Returns
Rpc<TModeledResponse>(string, object?)
Perform a stored procedure call.
public Task<TModeledResponse?> Rpc<TModeledResponse>(string procedureName, object? parameters = null)
Parameters
procedureNamestringThe function name to call
parametersobjectThe parameters to pass to the function call
Returns
- Task<TModeledResponse>
A hydrated model
Type Parameters
TModeledResponseA type used for hydrating the HTTP response content (hydration through JSON.NET)
SerializerSettings(ClientOptions?)
Custom Serializer resolvers and converters that will be used for encoding and decoding Postgrest JSON responses.
By default, Postgrest seems to use a date format that C# and Newtonsoft do not like, so this initial configuration handles that.
public static JsonSerializerSettings SerializerSettings(ClientOptions? options = null)
Parameters
optionsClientOptions
Returns
- JsonSerializerSettings
Table<T>()
Returns a Table Query Builder instance for a defined model - representative of USE $TABLE
public IPostgrestTable<T> Table<T>() where T : BaseModel, new()
Returns
Type Parameters
TCustom Model derived from
BaseModel
Table<T>(IPostgrestCacheProvider)
Returns a Table Query Builder instance with a Cache Provider for a defined model - representative of USE #$TABLE
public IPostgrestTableWithCache<T> Table<T>(IPostgrestCacheProvider cacheProvider) where T : BaseModel, new()
Parameters
cacheProviderIPostgrestCacheProvider
Returns
Type Parameters
T