You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you wish to add metadata for the user, you can pass it as part of the `data` parameter, just be sure to `import GoTrue` first to use the User metadata values.
- Setup Apple Auth as per [Supabase's Documentation](https://supabase.com/docs/guides/auth/social-login/auth-apple).
197
+
- Setup Apple Auth as per [Supabase's Documentation](https://supabase.com/docs/guides/auth/social-login/auth-apple).
175
198
- For Sign in with Apple follow the above as per Google Sign In and just replace the provider.
176
199
- Once the user moves to the `SFSafariViewController`, an Apple native pop-up will slide up to continue with the sign in.
177
200
@@ -197,8 +220,10 @@ First, import and initialize `SupabaseClient`, as explained in "Usage" section.
197
220
198
221
### Insert Data
199
222
223
+
- You can either use `Codable` or `Encodable` and `Decodable` protocols for the model's struct. However without either, you will get an error saying `Cannot convert value of type 'Void' to specified type 'InsertModel'` when trying to cast the response to your model.
200
224
- Create a model which follows your table's data structure:
201
225
226
+
202
227
```swift
203
228
structInsertModel: Encodable, Decodable {
204
229
let id: Int?// you can choose to omit this depending on how you've setup your table
@@ -213,7 +238,7 @@ let query = client.database
213
238
returning: .representation) // you will need to add this to return the added data
214
239
.select(columns: "id") // specifiy which column names to be returned. Leave it empty for all columns
215
240
.single() // specify you want to return a single value.
216
-
241
+
217
242
Task {
218
243
do {
219
244
let response: [InsertModel] =tryawait query.execute().value
@@ -235,13 +260,86 @@ let query = client.database
235
260
.select() // keep it empty for all, else specify returned data
returning: .representation) // you will need to add this to return the updated data
285
+
.select(columns: "id") // specifiy which column names to be returned. Leave it empty for all columns
286
+
.single() // specify you want to return a single value.
287
+
288
+
Task {
289
+
do {
290
+
let response: [InsertModel] =tryawait query.execute().value
291
+
print("### Returned: \(response)")
292
+
} catch {
293
+
print("### Update Error: \(error)")
294
+
}
295
+
}
296
+
```
297
+
298
+
### Delete Data
299
+
300
+
```swift
301
+
let query = client.database
302
+
.from("{ Your Table Name }")
303
+
.delete(returning: .representation) // you will need to add this to return the deleted data
304
+
.match(
305
+
query: ["id":1] // assuming the record above was inserted with id 1
306
+
// You can add additional conditions here
307
+
)
308
+
.select() // specifiy which column names to be returned. Leave it empty for all columns
309
+
.single()
310
+
311
+
Task {
312
+
do {
313
+
let response: [InsertModel] =tryawait query.execute().value
314
+
print("### Returned: \(response)")
315
+
} catch {
316
+
print("### Delete Error: \(error)")
317
+
}
318
+
}
319
+
```
320
+
321
+
## Postgres Functions
322
+
323
+
- Unlike the JavaScript library, you can't use the `rpc` method on the `SupabaseClient`, instead you need to use the `rpc` method on the `PostgresClient`:
0 commit comments