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
* Update sdk to use swift-native doc comments instead of jsdoc styled comments as per [Swift Documentation Comments](https://github.com/swiftlang/swift/blob/main/docs/DocumentationComments.md)
6
+
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
7
+
* Add `gif` support to `ImageFormat` enum
8
+
* Add `sequence` support to `Document` model
9
+
* Add `dart38` and `flutter332` support to runtime models
10
+
11
+
## 10.1.0
12
+
13
+
* Adds `upsertDocument` method
14
+
* Adds warnings to bulk operation methods
15
+
* Adds the new `encrypt` attribute
16
+
* Adds runtimes: `flutter332` and `dart38`
17
+
* Fix `select` Queries by updating internal attributes like `id`, `createdAt`, `updatedAt` etc. to be optional in `Document` model.
18
+
* Fix `listCollection` errors by updating `attributes` typing
19
+
* Fix querying datetime values by properly encoding URLs
20
+
21
+
## 10.0.0
22
+
23
+
* Add `<REGION>` to doc examples due to the new multi region endpoints
24
+
* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc.
25
+
* Add doc examples, class and methods for new `Sites` service
26
+
* Add doc examples, class and methods for new `Tokens` service
27
+
* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType`
28
+
* Update enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329
29
+
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
30
+
* Add `queries` and `search` params to `listMemberships` method
31
+
* Remove `search` param from `listExecutions` method
32
+
33
+
## 9.0.0
34
+
35
+
* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests
36
+
37
+
## 8.0.0
38
+
39
+
* Remove redundant titles from method descriptions.
40
+
* Add `codable` models
41
+
* Ensure response attribute in `AppwriteException` is always string
Copy file name to clipboardExpand all lines: README.md
+59-2Lines changed: 59 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Appwrite is an open-source backend as a service server that abstract and simplif
21
21
22
22
The Appwrite Swift SDK is available via Swift Package Manager. In order to use the Appwrite Swift SDK from Xcode, select File > **Add Packages**
23
23
24
-
In the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-swift.git) in the search field. Once found, select `sdk-for-apple`.
24
+
In the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-swift.git) in the search field. Once found, select `sdk-for-swift`.
25
25
26
26
On the right, select your version rules and ensure your desired target is selected in the **Add to Project** field.
27
27
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
The Appwrite Swift SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety.
124
+
125
+
```swift
126
+
structBook: Codable {
127
+
let name: String
128
+
let author: String
129
+
let releaseYear: String?
130
+
let category: String?
131
+
let genre: [String]?
132
+
let isCheckedOut: Bool
133
+
}
134
+
135
+
let databases =Databases(client)
136
+
137
+
do {
138
+
let documents =tryawait databases.listDocuments(
139
+
databaseId: "your-database-id",
140
+
collectionId: "your-collection-id",
141
+
nestedType: Book.self// Pass in your custom model type
142
+
)
143
+
144
+
for book in documents.documents {
145
+
print("Book: \(book.name) by \(book.author)") // Now you have full type safety
146
+
}
147
+
} catch {
148
+
print(error.localizedDescription)
149
+
}
150
+
```
151
+
152
+
**Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation).
153
+
154
+
### Working with Model Methods
155
+
156
+
All Appwrite models come with built-in methods for data conversion and manipulation:
157
+
158
+
**`toMap()`** - Converts a model instance to a dictionary format, useful for debugging or manual data manipulation:
159
+
```swift
160
+
let user =tryawait account.get()
161
+
let userMap = user.toMap()
162
+
print(userMap) // Prints all user properties as a dictionary
163
+
```
164
+
165
+
**`from(map:)`** - Creates a model instance from a dictionary, useful when working with raw data:
166
+
```swift
167
+
let userData: [String: Any] = ["$id":"123", "name":"John", "email":"john@example.com"]
168
+
let user = User.from(map: userData)
169
+
```
170
+
171
+
**`encode(to:)`** - Encodes the model to JSON format (part of Swift's Codable protocol), useful for serialization:
172
+
```swift
173
+
let user =tryawait account.get()
174
+
let jsonData =tryJSONEncoder().encode(user)
175
+
let jsonString =String(data: jsonData, encoding: .utf8)
176
+
```
177
+
121
178
### Error Handling
122
179
123
180
When an error occurs, the Appwrite Swift SDK throws an `AppwriteError` object with `message` and `code` properties. You can handle any errors in a catch block and present the `message` or `localizedDescription` to the user or handle it yourself based on the provided error information. Below is an example.
0 commit comments