Skip to content

Commit 2c7b0bb

Browse files
authored
Update README.md
1 parent f9b0781 commit 2c7b0bb

File tree

1 file changed

+2
-90
lines changed

1 file changed

+2
-90
lines changed

README.md

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let package = Package(
1212
...
1313
dependencies: [
1414
...
15-
.package(name: "Supabase", url: "https://github.com/supabase/supabase-swift.git", .exact("0.0.2")), // Add the package
15+
.package(name: "Supabase", url: "https://github.com/supabase/supabase-swift.git", branch: "master"), // Add the package
1616
],
1717
targets: [
1818
.target(
@@ -28,99 +28,11 @@ If you're using Xcode, [use this guide](https://developer.apple.com/documentatio
2828
## Usage
2929

3030
For all requests made for supabase, you will need to initialize a `SupabaseClient` object.
31-
```swift
32-
let client = SupabaseClient(supabaseUrl: "{ Supabase URL }", supabaseKey: "{ Supabase anonymous Key }")
33-
```
34-
This client object will be used for all the following examples.
35-
36-
### Database
37-
38-
Query todo table for all completed todos.
39-
```swift
40-
struct Todo: Codable {
41-
var id: String = UUID().uuidString
42-
var label: String
43-
var isDone: Bool = false
44-
}
45-
```
46-
47-
```swift
48-
let query = try client.database.from("todos")
49-
.select()
50-
.eq(column: "isDone", value: "true")
51-
52-
query.execute { [weak self] results in
53-
guard let self = self else { return }
54-
55-
switch results {
56-
case let .success(response):
57-
let todos = try? response.decoded(to: [Todo].self)
58-
print(todos)
59-
case let .failure(error):
60-
print(error.localizedDescription)
61-
}
62-
}
63-
```
64-
65-
Insert a todo into the database.
6631

6732
```swift
68-
let todo = Todo(label: "Example todo!")
69-
70-
let jsonData: Data = try JSONEncoder().encode(todo)
71-
let jsonDict: [String: Any] = try JSONSerialization.jsonObject(with: jsonData, options: .allowFragments))
72-
73-
client.database.from("todos")
74-
.insert(values: jsonDict)
75-
.execute { results in
76-
// Handle response
77-
}
78-
```
79-
80-
For more query examples visit [the Javascript docs](https://supabase.io/docs/reference/javascript/select) to learn more. The API design is a near 1:1 match.
81-
82-
Execute an RPC
83-
```swift
84-
do {
85-
try client.database.rpc(fn: "testFunction", parameters: nil).execute { result in
86-
// Handle result
87-
}
88-
} catch {
89-
print("Error executing the RPC: \(error)")
90-
}
91-
```
92-
93-
### Realtime
94-
95-
> Realtime docs coming soon
96-
97-
### Auth
98-
99-
Sign up with email and password
100-
```swift
101-
client.auth.signUp(email: "[email protected]", password: "password") { result in
102-
switch result {
103-
case let .success(session, user): print(user)
104-
case let .failure(error): print(error.localizedDescription)
105-
}
106-
}
107-
```
108-
109-
Login up with email and password
110-
```swift
111-
client.auth.signIn(email: "[email protected]", password: "password") { result in
112-
switch result {
113-
case let .success(session): print(session.accessToken, session.user)
114-
case let .failure(error): print(error.localizedDescription)
115-
}
116-
}
33+
let client = SupabaseClient(supabaseUrl: "{ Supabase URL }", supabaseKey: "{ Supabase anonymous Key }")
11734
```
11835

119-
### Storage
120-
121-
> Storage docs coming soon
122-
123-
12436
## Contributing
12537

12638
- Fork the repo on GitHub

0 commit comments

Comments
 (0)