diff --git a/apps/docs/docs/ref/csharp/initializing.mdx b/apps/docs/docs/ref/csharp/initializing.mdx deleted file mode 100644 index e9fbcca0a71..00000000000 --- a/apps/docs/docs/ref/csharp/initializing.mdx +++ /dev/null @@ -1,122 +0,0 @@ ---- -id: initializing -title: 'Initializing' -slug: initializing -custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml ---- - -### Initializing a new Client - - - - -Initializing a new client is pretty straightforward. Find your project url and public key from the -admin panel and pass it into your client initialization function. - -`supabase-csharp` is heavily dependent on Models deriving from `BaseModel`. To interact with the API, one must have the associated model (see example) specified. - -Leverage `Table`, `PrimaryKey`, and `Column` attributes to specify names of classes/properties that are different from their C# Versions. - - - - - - - - - ```csharp - var url = Environment.GetEnvironmentVariable("SUPABASE_URL"); - var key = Environment.GetEnvironmentVariable("SUPABASE_KEY"); - - var options = new Supabase.SupabaseOptions - { - AutoConnectRealtime = true - }; - - var supabase = new Supabase.Client(url, key, options); - await supabase.InitializeAsync(); - ``` - - - - - - ```csharp - public static MauiApp CreateMauiApp() - { - // ... - var builder = MauiApp.CreateBuilder(); - - var url = Environment.GetEnvironmentVariable("SUPABASE_URL"); - var key = Environment.GetEnvironmentVariable("SUPABASE_KEY"); - var options = new SupabaseOptions - { - AutoRefreshToken = true, - AutoConnectRealtime = true, - SessionHandler = new SupabaseSessionHandler() - }; - - // Note the creation as a singleton. - builder.Services.AddSingleton(provider => new Supabase.Client(url, key, options)); - } - ``` - - - - - ```csharp - // Given the following Model representing the Supabase Database (Message.cs) - [Table("messages")] - public class Message : BaseModel - { - [PrimaryKey("id")] - public int Id { get; set; } - - [Column("username")] - public string UserName { get; set; } - - [Column("channel_id")] - public int ChannelId { get; set; } - - public override bool Equals(object obj) - { - return obj is Message message && - Id == message.Id; - } - - public override int GetHashCode() - { - return HashCode.Combine(Id); - } - } - - void Initialize() - { - // Get All Messages - var response = await client.Table().Get(); - List models = response.Models; - - // Insert - var newMessage = new Message { UserName = "acupofjose", ChannelId = 1 }; - await client.Table().Insert(); - - // Update - var model = response.Models.First(); - model.UserName = "elrhomariyounes"; - await model.Update(); - - // Delete - await response.Models.Last().Delete(); - - // etc. - } - ``` - - - - - - diff --git a/spec/common-client-libs-sections.json b/spec/common-client-libs-sections.json index c48f87c6b99..ae606a8c005 100644 --- a/spec/common-client-libs-sections.json +++ b/spec/common-client-libs-sections.json @@ -10,14 +10,17 @@ "id": "installing", "slug": "installing", "type": "markdown", - "excludes": ["reference_javascript_v1", "reference_dart_v0", "reference_python_v2"] + "excludes": [ + "reference_javascript_v1", + "reference_dart_v0", + "reference_python_v2" + ] }, { "title": "Initializing", "id": "initializing", "slug": "initializing", - "type": "markdown", - "libs": ["csharp"] + "type": "function" }, { "title": "Typescript Support", @@ -367,7 +370,6 @@ "id": "auth-api", "title": "Overview", "slug": "auth-api", - "type": "function" }, { @@ -570,7 +572,6 @@ "id": "admin-api", "title": "Auth Admin", "slug": "admin-api", - "type": "function", "items": [ { @@ -704,7 +705,6 @@ "product": "realtime", "type": "function" }, - { "id": "remove-channel", "title": "Unsubscribe from a channel", @@ -847,7 +847,10 @@ }, { "title": "Misc", - "excludes": ["reference_dart_v1", "reference_dart_v0"], + "excludes": [ + "reference_dart_v1", + "reference_dart_v0" + ], "items": [ { "title": "Release Notes", @@ -858,4 +861,4 @@ } ] } -] +] \ No newline at end of file diff --git a/spec/supabase_csharp_v0.yml b/spec/supabase_csharp_v0.yml index 9f2c963685b..a83d003bd2a 100644 --- a/spec/supabase_csharp_v0.yml +++ b/spec/supabase_csharp_v0.yml @@ -16,6 +16,104 @@ info: version: '0.8.0' functions: + - id: initializing + title: Initializing + description: | + Initializing a new client is pretty straightforward. Find your project url and public key from the + admin panel and pass it into your client initialization function. + + `supabase-csharp` is heavily dependent on Models deriving from `BaseModel`. To interact with the API, one must have the associated model (see example) specified. + + Leverage `Table`, `PrimaryKey`, and `Column` attributes to specify names of classes/properties that are different from their C# Versions. + + examples: + - id: csharp-init-standard + name: Standard + code: | + ```c# + var url = Environment.GetEnvironmentVariable("SUPABASE_URL"); + var key = Environment.GetEnvironmentVariable("SUPABASE_KEY"); + + var options = new Supabase.SupabaseOptions + { + AutoConnectRealtime = true + }; + + var supabase = new Supabase.Client(url, key, options); + await supabase.InitializeAsync(); + ``` + - id: csharp-init-maui + name: Dependency Injection (Maui-like) + code: | + ```c# + public static MauiApp CreateMauiApp() + { + // ... + var builder = MauiApp.CreateBuilder(); + + var url = Environment.GetEnvironmentVariable("SUPABASE_URL"); + var key = Environment.GetEnvironmentVariable("SUPABASE_KEY"); + var options = new SupabaseOptions + { + AutoRefreshToken = true, + AutoConnectRealtime = true, + SessionHandler = new SupabaseSessionHandler() + }; + + // Note the creation as a singleton. + builder.Services.AddSingleton(provider => new Supabase.Client(url, key, options)); + } + ``` + - id: csharp-init-showing-models + name: With Models Example + code: | + ```c# + // Given the following Model representing the Supabase Database (Message.cs) + [Table("messages")] + public class Message : BaseModel + { + [PrimaryKey("id")] + public int Id { get; set; } + + [Column("username")] + public string UserName { get; set; } + + [Column("channel_id")] + public int ChannelId { get; set; } + + public override bool Equals(object obj) + { + return obj is Message message && + Id == message.Id; + } + + public override int GetHashCode() + { + return HashCode.Combine(Id); + } + } + + void Initialize() + { + // Get All Messages + var response = await client.Table().Get(); + List models = response.Models; + + // Insert + var newMessage = new Message { UserName = "acupofjose", ChannelId = 1 }; + await client.Table().Insert(); + + // Update + var model = response.Models.First(); + model.UserName = "elrhomariyounes"; + await model.Update(); + + // Delete + await response.Models.Last().Delete(); + + // etc. + } + ``` - id: sign-up title: 'SignUp()' description: | diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.yml index 4283df18eca..be1fef2532e 100644 --- a/spec/supabase_js_v2.yml +++ b/spec/supabase_js_v2.yml @@ -66,9 +66,9 @@ functions: db: { schema: 'other_schema' } }) ``` - + description: | By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard. - Go to `Settings > API > Schema` and add the schema which you want to expose to the API. + Go to [Settings > API > Exposed schemas](https://app.supabase.com/project/_/settings/api) and add the schema which you want to expose to the API. Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema. - id: custom-fetch-implementation @@ -81,7 +81,7 @@ functions: global: { fetch: fetch.bind(globalThis) } }) ``` - + description: | `supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests, but an alternative `fetch` implementation can be provided as an option. This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers). @@ -101,7 +101,7 @@ functions: }, }); ``` - + description: | For React Native we recommend using `AsyncStorage` as the storage implementation for Supabase Auth. - id: auth-api title: 'Overview'