@@ -25,9 +25,11 @@ This is a basic task which inserts a new row into a table from a Trigger.dev tas
25
25
``` ts trigger/supabase-database-insert.ts
26
26
import { createClient } from " @supabase/supabase-js" ;
27
27
import { task } from " @trigger.dev/sdk/v3" ;
28
+ // Generate the Typescript types using the Supabase CLI: https://supabase.com/docs/guides/api/rest/generating-types
28
29
import { Database } from " database.types" ;
29
30
30
31
// Create a single Supabase client for interacting with your database
32
+ // 'Database' supplies the type definitions to supabase-js
31
33
const supabase = createClient <Database >(
32
34
// These details can be found in your Supabase project settings under `API`
33
35
process .env .SUPABASE_PROJECT_URL as string , // e.g. https://abc123.supabase.co - replace 'abc123' with your project ID
@@ -93,6 +95,7 @@ This type of task is useful for managing user subscriptions, updating user detai
93
95
- A [ Supabase account] ( https://supabase.com/dashboard/ ) and a project set up
94
96
- In your Supabase project, create a table called ` user_subscriptions ` (if you haven't already)
95
97
- In your ` user_subscriptions ` table, create these columns (if they don't already exist):
98
+
96
99
- ` user_id ` , with the data type: ` text `
97
100
- ` plan ` , with the data type: ` text `
98
101
- ` updated_at ` , with the data type: ` timestamptz `
@@ -102,12 +105,14 @@ This type of task is useful for managing user subscriptions, updating user detai
102
105
``` ts trigger/supabase-update-user-subscription.ts
103
106
import { createClient } from " @supabase/supabase-js" ;
104
107
import { AbortTaskRunError , task } from " @trigger.dev/sdk/v3" ;
108
+ // Generate the Typescript types using the Supabase CLI: https://supabase.com/docs/guides/api/rest/generating-types
105
109
import { Database } from " database.types" ;
106
110
107
111
// Define the allowed plan types
108
112
type PlanType = " hobby" | " pro" | " enterprise" ;
109
113
110
114
// Create a single Supabase client for interacting with your database
115
+ // 'Database' supplies the type definitions to supabase-js
111
116
const supabase = createClient <Database >(
112
117
// These details can be found in your Supabase project settings under `API`
113
118
process .env .SUPABASE_PROJECT_URL as string , // e.g. https://abc123.supabase.co - replace 'abc123' with your project ID
0 commit comments