mirror of
https://github.com/appwrite/sdk-for-swift.git
synced 2026-04-07 19:17:48 +00:00
Add transactions
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Change Log
|
||||
|
||||
## 13.2.0
|
||||
|
||||
* Add transaction support for Databases and TablesDB
|
||||
|
||||
## 13.1.0
|
||||
|
||||
* Deprecate `createVerification` method in `Account` service
|
||||
|
||||
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
|
||||
|
||||
```swift
|
||||
dependencies: [
|
||||
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.1.0"),
|
||||
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "13.2.0"),
|
||||
],
|
||||
```
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ open class Client {
|
||||
"x-sdk-name": "Swift",
|
||||
"x-sdk-platform": "server",
|
||||
"x-sdk-language": "swift",
|
||||
"x-sdk-version": "13.1.0",
|
||||
"x-sdk-version": "13.2.0",
|
||||
"x-appwrite-response-format": "1.8.0"
|
||||
]
|
||||
|
||||
|
||||
@@ -87,6 +87,207 @@ open class Databases: Service {
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// List transactions across all databases.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - queries: [String] (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.TransactionList
|
||||
///
|
||||
open func listTransactions(
|
||||
queries: [String]? = nil
|
||||
) async throws -> AppwriteModels.TransactionList {
|
||||
let apiPath: String = "/databases/transactions"
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.TransactionList = { response in
|
||||
return AppwriteModels.TransactionList.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "GET",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Create a new transaction.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - ttl: Int (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func createTransaction(
|
||||
ttl: Int? = nil
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/databases/transactions"
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"ttl": ttl
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "POST",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Get a transaction by its unique ID.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func getTransaction(
|
||||
transactionId: String
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/databases/transactions/{transactionId}"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any] = [:]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "GET",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Update a transaction, to either commit or roll back its operations.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - commit: Bool (optional)
|
||||
/// - rollback: Bool (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func updateTransaction(
|
||||
transactionId: String,
|
||||
commit: Bool? = nil,
|
||||
rollback: Bool? = nil
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/databases/transactions/{transactionId}"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"commit": commit,
|
||||
"rollback": rollback
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "PATCH",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Delete a transaction by its unique ID.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: Any
|
||||
///
|
||||
open func deleteTransaction(
|
||||
transactionId: String
|
||||
) async throws -> Any {
|
||||
let apiPath: String = "/databases/transactions/{transactionId}"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any] = [:]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
return try await client.call(
|
||||
method: "DELETE",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams )
|
||||
}
|
||||
|
||||
///
|
||||
/// Create multiple operations in a single transaction.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - operations: [Any] (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func createOperations(
|
||||
transactionId: String,
|
||||
operations: [Any]? = nil
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/databases/transactions/{transactionId}/operations"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"operations": operations
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "POST",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Get a database by its unique ID. This endpoint response returns a JSON
|
||||
/// object with the database metadata.
|
||||
@@ -1881,6 +2082,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -1889,6 +2091,7 @@ open class Databases: Service {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.DocumentList<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -1896,7 +2099,8 @@ open class Databases: Service {
|
||||
.replacingOccurrences(of: "{collectionId}", with: collectionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
@@ -1922,6 +2126,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -1929,12 +2134,14 @@ open class Databases: Service {
|
||||
open func listDocuments(
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
|
||||
return try await listDocuments(
|
||||
databaseId: databaseId,
|
||||
collectionId: collectionId,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -1951,6 +2158,7 @@ open class Databases: Service {
|
||||
/// - documentId: String
|
||||
/// - data: Any
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -1961,6 +2169,7 @@ open class Databases: Service {
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Document<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -1970,7 +2179,8 @@ open class Databases: Service {
|
||||
let apiParams: [String: Any?] = [
|
||||
"documentId": documentId,
|
||||
"data": data,
|
||||
"permissions": permissions
|
||||
"permissions": permissions,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2002,6 +2212,7 @@ open class Databases: Service {
|
||||
/// - documentId: String
|
||||
/// - data: Any
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2011,7 +2222,8 @@ open class Databases: Service {
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: [String]? = nil
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
|
||||
return try await createDocument(
|
||||
databaseId: databaseId,
|
||||
@@ -2019,6 +2231,7 @@ open class Databases: Service {
|
||||
documentId: documentId,
|
||||
data: data,
|
||||
permissions: permissions,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2033,6 +2246,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - documents: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2041,6 +2255,7 @@ open class Databases: Service {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
documents: [Any],
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.DocumentList<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -2048,7 +2263,8 @@ open class Databases: Service {
|
||||
.replacingOccurrences(of: "{collectionId}", with: collectionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"documents": documents
|
||||
"documents": documents,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2078,6 +2294,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - documents: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2085,12 +2302,14 @@ open class Databases: Service {
|
||||
open func createDocuments(
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
documents: [Any]
|
||||
documents: [Any],
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
|
||||
return try await createDocuments(
|
||||
databaseId: databaseId,
|
||||
collectionId: collectionId,
|
||||
documents: documents,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2106,6 +2325,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - documents: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2114,6 +2334,7 @@ open class Databases: Service {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
documents: [Any],
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.DocumentList<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -2121,7 +2342,8 @@ open class Databases: Service {
|
||||
.replacingOccurrences(of: "{collectionId}", with: collectionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"documents": documents
|
||||
"documents": documents,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2152,6 +2374,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - documents: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2159,12 +2382,14 @@ open class Databases: Service {
|
||||
open func upsertDocuments(
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
documents: [Any]
|
||||
documents: [Any],
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
|
||||
return try await upsertDocuments(
|
||||
databaseId: databaseId,
|
||||
collectionId: collectionId,
|
||||
documents: documents,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2179,6 +2404,7 @@ open class Databases: Service {
|
||||
/// - collectionId: String
|
||||
/// - data: Any (optional)
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2188,6 +2414,7 @@ open class Databases: Service {
|
||||
collectionId: String,
|
||||
data: Any? = nil,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.DocumentList<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -2196,7 +2423,8 @@ open class Databases: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"data": data,
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2226,6 +2454,7 @@ open class Databases: Service {
|
||||
/// - collectionId: String
|
||||
/// - data: Any (optional)
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2234,13 +2463,15 @@ open class Databases: Service {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
data: Any? = nil,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
|
||||
return try await updateDocuments(
|
||||
databaseId: databaseId,
|
||||
collectionId: collectionId,
|
||||
data: data,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2253,6 +2484,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2261,6 +2493,7 @@ open class Databases: Service {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.DocumentList<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -2268,7 +2501,8 @@ open class Databases: Service {
|
||||
.replacingOccurrences(of: "{collectionId}", with: collectionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2296,6 +2530,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.DocumentList<T>
|
||||
///
|
||||
@@ -2303,12 +2538,14 @@ open class Databases: Service {
|
||||
open func deleteDocuments(
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.DocumentList<[String: AnyCodable]> {
|
||||
return try await deleteDocuments(
|
||||
databaseId: databaseId,
|
||||
collectionId: collectionId,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2322,6 +2559,7 @@ open class Databases: Service {
|
||||
/// - collectionId: String
|
||||
/// - documentId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2331,6 +2569,7 @@ open class Databases: Service {
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Document<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
@@ -2339,7 +2578,8 @@ open class Databases: Service {
|
||||
.replacingOccurrences(of: "{documentId}", with: documentId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
@@ -2366,6 +2606,7 @@ open class Databases: Service {
|
||||
/// - collectionId: String
|
||||
/// - documentId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2374,13 +2615,15 @@ open class Databases: Service {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
|
||||
return try await getDocument(
|
||||
databaseId: databaseId,
|
||||
collectionId: collectionId,
|
||||
documentId: documentId,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2397,6 +2640,7 @@ open class Databases: Service {
|
||||
/// - documentId: String
|
||||
/// - data: Any
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2407,6 +2651,7 @@ open class Databases: Service {
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Document<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
@@ -2416,7 +2661,8 @@ open class Databases: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"data": data,
|
||||
"permissions": permissions
|
||||
"permissions": permissions,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2448,6 +2694,7 @@ open class Databases: Service {
|
||||
/// - documentId: String
|
||||
/// - data: Any
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2457,7 +2704,8 @@ open class Databases: Service {
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: [String]? = nil
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
|
||||
return try await upsertDocument(
|
||||
databaseId: databaseId,
|
||||
@@ -2465,6 +2713,7 @@ open class Databases: Service {
|
||||
documentId: documentId,
|
||||
data: data,
|
||||
permissions: permissions,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2479,6 +2728,7 @@ open class Databases: Service {
|
||||
/// - documentId: String
|
||||
/// - data: Any (optional)
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2489,6 +2739,7 @@ open class Databases: Service {
|
||||
documentId: String,
|
||||
data: Any? = nil,
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Document<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
@@ -2498,7 +2749,8 @@ open class Databases: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"data": data,
|
||||
"permissions": permissions
|
||||
"permissions": permissions,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2528,6 +2780,7 @@ open class Databases: Service {
|
||||
/// - documentId: String
|
||||
/// - data: Any (optional)
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2537,7 +2790,8 @@ open class Databases: Service {
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
data: Any? = nil,
|
||||
permissions: [String]? = nil
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
|
||||
return try await updateDocument(
|
||||
databaseId: databaseId,
|
||||
@@ -2545,6 +2799,7 @@ open class Databases: Service {
|
||||
documentId: documentId,
|
||||
data: data,
|
||||
permissions: permissions,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2556,6 +2811,7 @@ open class Databases: Service {
|
||||
/// - databaseId: String
|
||||
/// - collectionId: String
|
||||
/// - documentId: String
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: Any
|
||||
///
|
||||
@@ -2563,14 +2819,17 @@ open class Databases: Service {
|
||||
open func deleteDocument(
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
documentId: String
|
||||
documentId: String,
|
||||
transactionId: String? = nil
|
||||
) async throws -> Any {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
.replacingOccurrences(of: "{databaseId}", with: databaseId)
|
||||
.replacingOccurrences(of: "{collectionId}", with: collectionId)
|
||||
.replacingOccurrences(of: "{documentId}", with: documentId)
|
||||
|
||||
let apiParams: [String: Any] = [:]
|
||||
let apiParams: [String: Any?] = [
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
@@ -2593,6 +2852,7 @@ open class Databases: Service {
|
||||
/// - attribute: String
|
||||
/// - value: Double (optional)
|
||||
/// - min: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2604,6 +2864,7 @@ open class Databases: Service {
|
||||
attribute: String,
|
||||
value: Double? = nil,
|
||||
min: Double? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Document<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement"
|
||||
@@ -2614,7 +2875,8 @@ open class Databases: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"value": value,
|
||||
"min": min
|
||||
"min": min,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2644,6 +2906,7 @@ open class Databases: Service {
|
||||
/// - attribute: String
|
||||
/// - value: Double (optional)
|
||||
/// - min: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2654,7 +2917,8 @@ open class Databases: Service {
|
||||
documentId: String,
|
||||
attribute: String,
|
||||
value: Double? = nil,
|
||||
min: Double? = nil
|
||||
min: Double? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
|
||||
return try await decrementDocumentAttribute(
|
||||
databaseId: databaseId,
|
||||
@@ -2663,6 +2927,7 @@ open class Databases: Service {
|
||||
attribute: attribute,
|
||||
value: value,
|
||||
min: min,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2677,6 +2942,7 @@ open class Databases: Service {
|
||||
/// - attribute: String
|
||||
/// - value: Double (optional)
|
||||
/// - max: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2688,6 +2954,7 @@ open class Databases: Service {
|
||||
attribute: String,
|
||||
value: Double? = nil,
|
||||
max: Double? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Document<T> {
|
||||
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment"
|
||||
@@ -2698,7 +2965,8 @@ open class Databases: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"value": value,
|
||||
"max": max
|
||||
"max": max,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2728,6 +2996,7 @@ open class Databases: Service {
|
||||
/// - attribute: String
|
||||
/// - value: Double (optional)
|
||||
/// - max: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Document<T>
|
||||
///
|
||||
@@ -2738,7 +3007,8 @@ open class Databases: Service {
|
||||
documentId: String,
|
||||
attribute: String,
|
||||
value: Double? = nil,
|
||||
max: Double? = nil
|
||||
max: Double? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
|
||||
return try await incrementDocumentAttribute(
|
||||
databaseId: databaseId,
|
||||
@@ -2747,6 +3017,7 @@ open class Databases: Service {
|
||||
attribute: attribute,
|
||||
value: value,
|
||||
max: max,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2846,7 +3117,7 @@ open class Databases: Service {
|
||||
}
|
||||
|
||||
///
|
||||
/// Get index by ID.
|
||||
/// Get an index by its unique ID.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - databaseId: String
|
||||
|
||||
@@ -85,6 +85,207 @@ open class TablesDB: Service {
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// List transactions across all databases.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - queries: [String] (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.TransactionList
|
||||
///
|
||||
open func listTransactions(
|
||||
queries: [String]? = nil
|
||||
) async throws -> AppwriteModels.TransactionList {
|
||||
let apiPath: String = "/tablesdb/transactions"
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.TransactionList = { response in
|
||||
return AppwriteModels.TransactionList.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "GET",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Create a new transaction.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - ttl: Int (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func createTransaction(
|
||||
ttl: Int? = nil
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/tablesdb/transactions"
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"ttl": ttl
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "POST",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Get a transaction by its unique ID.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func getTransaction(
|
||||
transactionId: String
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/tablesdb/transactions/{transactionId}"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any] = [:]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "GET",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Update a transaction, to either commit or roll back its operations.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - commit: Bool (optional)
|
||||
/// - rollback: Bool (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func updateTransaction(
|
||||
transactionId: String,
|
||||
commit: Bool? = nil,
|
||||
rollback: Bool? = nil
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/tablesdb/transactions/{transactionId}"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"commit": commit,
|
||||
"rollback": rollback
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "PATCH",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Delete a transaction by its unique ID.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: Any
|
||||
///
|
||||
open func deleteTransaction(
|
||||
transactionId: String
|
||||
) async throws -> Any {
|
||||
let apiPath: String = "/tablesdb/transactions/{transactionId}"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any] = [:]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
return try await client.call(
|
||||
method: "DELETE",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams )
|
||||
}
|
||||
|
||||
///
|
||||
/// Create multiple operations in a single transaction.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - transactionId: String
|
||||
/// - operations: [Any] (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Transaction
|
||||
///
|
||||
open func createOperations(
|
||||
transactionId: String,
|
||||
operations: [Any]? = nil
|
||||
) async throws -> AppwriteModels.Transaction {
|
||||
let apiPath: String = "/tablesdb/transactions/{transactionId}/operations"
|
||||
.replacingOccurrences(of: "{transactionId}", with: transactionId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"operations": operations
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
]
|
||||
|
||||
let converter: (Any) -> AppwriteModels.Transaction = { response in
|
||||
return AppwriteModels.Transaction.from(map: response as! [String: Any])
|
||||
}
|
||||
|
||||
return try await client.call(
|
||||
method: "POST",
|
||||
path: apiPath,
|
||||
headers: apiHeaders,
|
||||
params: apiParams,
|
||||
converter: converter
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Get a database by its unique ID. This endpoint response returns a JSON
|
||||
/// object with the database metadata.
|
||||
@@ -2003,6 +2204,7 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
@@ -2010,6 +2212,7 @@ open class TablesDB: Service {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.RowList<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -2017,7 +2220,8 @@ open class TablesDB: Service {
|
||||
.replacingOccurrences(of: "{tableId}", with: tableId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
@@ -2043,18 +2247,21 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
open func listRows(
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.RowList<[String: AnyCodable]> {
|
||||
return try await listRows(
|
||||
databaseId: databaseId,
|
||||
tableId: tableId,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2071,6 +2278,7 @@ open class TablesDB: Service {
|
||||
/// - rowId: String
|
||||
/// - data: Any
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2080,6 +2288,7 @@ open class TablesDB: Service {
|
||||
rowId: String,
|
||||
data: Any,
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Row<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -2089,7 +2298,8 @@ open class TablesDB: Service {
|
||||
let apiParams: [String: Any?] = [
|
||||
"rowId": rowId,
|
||||
"data": data,
|
||||
"permissions": permissions
|
||||
"permissions": permissions,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2121,6 +2331,7 @@ open class TablesDB: Service {
|
||||
/// - rowId: String
|
||||
/// - data: Any
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2129,7 +2340,8 @@ open class TablesDB: Service {
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
data: Any,
|
||||
permissions: [String]? = nil
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Row<[String: AnyCodable]> {
|
||||
return try await createRow(
|
||||
databaseId: databaseId,
|
||||
@@ -2137,6 +2349,7 @@ open class TablesDB: Service {
|
||||
rowId: rowId,
|
||||
data: data,
|
||||
permissions: permissions,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2151,6 +2364,7 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - rows: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
@@ -2158,6 +2372,7 @@ open class TablesDB: Service {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
rows: [Any],
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.RowList<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -2165,7 +2380,8 @@ open class TablesDB: Service {
|
||||
.replacingOccurrences(of: "{tableId}", with: tableId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"rows": rows
|
||||
"rows": rows,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2195,18 +2411,21 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - rows: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
open func createRows(
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
rows: [Any]
|
||||
rows: [Any],
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.RowList<[String: AnyCodable]> {
|
||||
return try await createRows(
|
||||
databaseId: databaseId,
|
||||
tableId: tableId,
|
||||
rows: rows,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2222,6 +2441,7 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - rows: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
@@ -2229,6 +2449,7 @@ open class TablesDB: Service {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
rows: [Any],
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.RowList<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -2236,7 +2457,8 @@ open class TablesDB: Service {
|
||||
.replacingOccurrences(of: "{tableId}", with: tableId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"rows": rows
|
||||
"rows": rows,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2267,18 +2489,21 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - rows: [Any]
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
open func upsertRows(
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
rows: [Any]
|
||||
rows: [Any],
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.RowList<[String: AnyCodable]> {
|
||||
return try await upsertRows(
|
||||
databaseId: databaseId,
|
||||
tableId: tableId,
|
||||
rows: rows,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2292,6 +2517,7 @@ open class TablesDB: Service {
|
||||
/// - tableId: String
|
||||
/// - data: Any (optional)
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
@@ -2300,6 +2526,7 @@ open class TablesDB: Service {
|
||||
tableId: String,
|
||||
data: Any? = nil,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.RowList<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -2308,7 +2535,8 @@ open class TablesDB: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"data": data,
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2337,6 +2565,7 @@ open class TablesDB: Service {
|
||||
/// - tableId: String
|
||||
/// - data: Any (optional)
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
@@ -2344,13 +2573,15 @@ open class TablesDB: Service {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
data: Any? = nil,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.RowList<[String: AnyCodable]> {
|
||||
return try await updateRows(
|
||||
databaseId: databaseId,
|
||||
tableId: tableId,
|
||||
data: data,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2363,6 +2594,7 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
@@ -2370,6 +2602,7 @@ open class TablesDB: Service {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.RowList<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -2377,7 +2610,8 @@ open class TablesDB: Service {
|
||||
.replacingOccurrences(of: "{tableId}", with: tableId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2405,18 +2639,21 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.RowList<T>
|
||||
///
|
||||
open func deleteRows(
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.RowList<[String: AnyCodable]> {
|
||||
return try await deleteRows(
|
||||
databaseId: databaseId,
|
||||
tableId: tableId,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2430,6 +2667,7 @@ open class TablesDB: Service {
|
||||
/// - tableId: String
|
||||
/// - rowId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2438,6 +2676,7 @@ open class TablesDB: Service {
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Row<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
@@ -2446,7 +2685,8 @@ open class TablesDB: Service {
|
||||
.replacingOccurrences(of: "{rowId}", with: rowId)
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"queries": queries
|
||||
"queries": queries,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [:]
|
||||
@@ -2473,6 +2713,7 @@ open class TablesDB: Service {
|
||||
/// - tableId: String
|
||||
/// - rowId: String
|
||||
/// - queries: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2480,13 +2721,15 @@ open class TablesDB: Service {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
queries: [String]? = nil
|
||||
queries: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Row<[String: AnyCodable]> {
|
||||
return try await getRow(
|
||||
databaseId: databaseId,
|
||||
tableId: tableId,
|
||||
rowId: rowId,
|
||||
queries: queries,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2503,6 +2746,7 @@ open class TablesDB: Service {
|
||||
/// - rowId: String
|
||||
/// - data: Any (optional)
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2512,6 +2756,7 @@ open class TablesDB: Service {
|
||||
rowId: String,
|
||||
data: Any? = nil,
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Row<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
@@ -2521,7 +2766,8 @@ open class TablesDB: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"data": data,
|
||||
"permissions": permissions
|
||||
"permissions": permissions,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2553,6 +2799,7 @@ open class TablesDB: Service {
|
||||
/// - rowId: String
|
||||
/// - data: Any (optional)
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2561,7 +2808,8 @@ open class TablesDB: Service {
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
data: Any? = nil,
|
||||
permissions: [String]? = nil
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Row<[String: AnyCodable]> {
|
||||
return try await upsertRow(
|
||||
databaseId: databaseId,
|
||||
@@ -2569,6 +2817,7 @@ open class TablesDB: Service {
|
||||
rowId: rowId,
|
||||
data: data,
|
||||
permissions: permissions,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2583,6 +2832,7 @@ open class TablesDB: Service {
|
||||
/// - rowId: String
|
||||
/// - data: Any (optional)
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2592,6 +2842,7 @@ open class TablesDB: Service {
|
||||
rowId: String,
|
||||
data: Any? = nil,
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Row<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
@@ -2601,7 +2852,8 @@ open class TablesDB: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"data": data,
|
||||
"permissions": permissions
|
||||
"permissions": permissions,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2631,6 +2883,7 @@ open class TablesDB: Service {
|
||||
/// - rowId: String
|
||||
/// - data: Any (optional)
|
||||
/// - permissions: [String] (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2639,7 +2892,8 @@ open class TablesDB: Service {
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
data: Any? = nil,
|
||||
permissions: [String]? = nil
|
||||
permissions: [String]? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Row<[String: AnyCodable]> {
|
||||
return try await updateRow(
|
||||
databaseId: databaseId,
|
||||
@@ -2647,6 +2901,7 @@ open class TablesDB: Service {
|
||||
rowId: rowId,
|
||||
data: data,
|
||||
permissions: permissions,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2658,20 +2913,24 @@ open class TablesDB: Service {
|
||||
/// - databaseId: String
|
||||
/// - tableId: String
|
||||
/// - rowId: String
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: Any
|
||||
///
|
||||
open func deleteRow(
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
rowId: String
|
||||
rowId: String,
|
||||
transactionId: String? = nil
|
||||
) async throws -> Any {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
.replacingOccurrences(of: "{databaseId}", with: databaseId)
|
||||
.replacingOccurrences(of: "{tableId}", with: tableId)
|
||||
.replacingOccurrences(of: "{rowId}", with: rowId)
|
||||
|
||||
let apiParams: [String: Any] = [:]
|
||||
let apiParams: [String: Any?] = [
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
"content-type": "application/json"
|
||||
@@ -2694,6 +2953,7 @@ open class TablesDB: Service {
|
||||
/// - column: String
|
||||
/// - value: Double (optional)
|
||||
/// - min: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2704,6 +2964,7 @@ open class TablesDB: Service {
|
||||
column: String,
|
||||
value: Double? = nil,
|
||||
min: Double? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Row<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement"
|
||||
@@ -2714,7 +2975,8 @@ open class TablesDB: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"value": value,
|
||||
"min": min
|
||||
"min": min,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2744,6 +3006,7 @@ open class TablesDB: Service {
|
||||
/// - column: String
|
||||
/// - value: Double (optional)
|
||||
/// - min: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2753,7 +3016,8 @@ open class TablesDB: Service {
|
||||
rowId: String,
|
||||
column: String,
|
||||
value: Double? = nil,
|
||||
min: Double? = nil
|
||||
min: Double? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Row<[String: AnyCodable]> {
|
||||
return try await decrementRowColumn(
|
||||
databaseId: databaseId,
|
||||
@@ -2762,6 +3026,7 @@ open class TablesDB: Service {
|
||||
column: column,
|
||||
value: value,
|
||||
min: min,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
@@ -2776,6 +3041,7 @@ open class TablesDB: Service {
|
||||
/// - column: String
|
||||
/// - value: Double (optional)
|
||||
/// - max: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2786,6 +3052,7 @@ open class TablesDB: Service {
|
||||
column: String,
|
||||
value: Double? = nil,
|
||||
max: Double? = nil,
|
||||
transactionId: String? = nil,
|
||||
nestedType: T.Type
|
||||
) async throws -> AppwriteModels.Row<T> {
|
||||
let apiPath: String = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment"
|
||||
@@ -2796,7 +3063,8 @@ open class TablesDB: Service {
|
||||
|
||||
let apiParams: [String: Any?] = [
|
||||
"value": value,
|
||||
"max": max
|
||||
"max": max,
|
||||
"transactionId": transactionId
|
||||
]
|
||||
|
||||
let apiHeaders: [String: String] = [
|
||||
@@ -2826,6 +3094,7 @@ open class TablesDB: Service {
|
||||
/// - column: String
|
||||
/// - value: Double (optional)
|
||||
/// - max: Double (optional)
|
||||
/// - transactionId: String (optional)
|
||||
/// - Throws: Exception if the request fails
|
||||
/// - Returns: AppwriteModels.Row<T>
|
||||
///
|
||||
@@ -2835,7 +3104,8 @@ open class TablesDB: Service {
|
||||
rowId: String,
|
||||
column: String,
|
||||
value: Double? = nil,
|
||||
max: Double? = nil
|
||||
max: Double? = nil,
|
||||
transactionId: String? = nil
|
||||
) async throws -> AppwriteModels.Row<[String: AnyCodable]> {
|
||||
return try await incrementRowColumn(
|
||||
databaseId: databaseId,
|
||||
@@ -2844,6 +3114,7 @@ open class TablesDB: Service {
|
||||
column: column,
|
||||
value: value,
|
||||
max: max,
|
||||
transactionId: transactionId,
|
||||
nestedType: [String: AnyCodable].self
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import Foundation
|
||||
import JSONCodable
|
||||
|
||||
/// Transaction
|
||||
open class Transaction: Codable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id = "$id"
|
||||
case createdAt = "$createdAt"
|
||||
case updatedAt = "$updatedAt"
|
||||
case status = "status"
|
||||
case operations = "operations"
|
||||
case expiresAt = "expiresAt"
|
||||
}
|
||||
|
||||
/// Transaction ID.
|
||||
public let id: String
|
||||
|
||||
/// Transaction creation time in ISO 8601 format.
|
||||
public let createdAt: String
|
||||
|
||||
/// Transaction update date in ISO 8601 format.
|
||||
public let updatedAt: String
|
||||
|
||||
/// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed.
|
||||
public let status: String
|
||||
|
||||
/// Number of operations in the transaction.
|
||||
public let operations: Int
|
||||
|
||||
/// Expiration time in ISO 8601 format.
|
||||
public let expiresAt: String
|
||||
|
||||
|
||||
init(
|
||||
id: String,
|
||||
createdAt: String,
|
||||
updatedAt: String,
|
||||
status: String,
|
||||
operations: Int,
|
||||
expiresAt: String
|
||||
) {
|
||||
self.id = id
|
||||
self.createdAt = createdAt
|
||||
self.updatedAt = updatedAt
|
||||
self.status = status
|
||||
self.operations = operations
|
||||
self.expiresAt = expiresAt
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
self.id = try container.decode(String.self, forKey: .id)
|
||||
self.createdAt = try container.decode(String.self, forKey: .createdAt)
|
||||
self.updatedAt = try container.decode(String.self, forKey: .updatedAt)
|
||||
self.status = try container.decode(String.self, forKey: .status)
|
||||
self.operations = try container.decode(Int.self, forKey: .operations)
|
||||
self.expiresAt = try container.decode(String.self, forKey: .expiresAt)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
try container.encode(id, forKey: .id)
|
||||
try container.encode(createdAt, forKey: .createdAt)
|
||||
try container.encode(updatedAt, forKey: .updatedAt)
|
||||
try container.encode(status, forKey: .status)
|
||||
try container.encode(operations, forKey: .operations)
|
||||
try container.encode(expiresAt, forKey: .expiresAt)
|
||||
}
|
||||
|
||||
public func toMap() -> [String: Any] {
|
||||
return [
|
||||
"$id": id as Any,
|
||||
"$createdAt": createdAt as Any,
|
||||
"$updatedAt": updatedAt as Any,
|
||||
"status": status as Any,
|
||||
"operations": operations as Any,
|
||||
"expiresAt": expiresAt as Any
|
||||
]
|
||||
}
|
||||
|
||||
public static func from(map: [String: Any] ) -> Transaction {
|
||||
return Transaction(
|
||||
id: map["$id"] as! String,
|
||||
createdAt: map["$createdAt"] as! String,
|
||||
updatedAt: map["$updatedAt"] as! String,
|
||||
status: map["status"] as! String,
|
||||
operations: map["operations"] as! Int,
|
||||
expiresAt: map["expiresAt"] as! String
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import Foundation
|
||||
import JSONCodable
|
||||
|
||||
/// Transaction List
|
||||
open class TransactionList: Codable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case total = "total"
|
||||
case transactions = "transactions"
|
||||
}
|
||||
|
||||
/// Total number of transactions that matched your query.
|
||||
public let total: Int
|
||||
|
||||
/// List of transactions.
|
||||
public let transactions: [Transaction]
|
||||
|
||||
|
||||
init(
|
||||
total: Int,
|
||||
transactions: [Transaction]
|
||||
) {
|
||||
self.total = total
|
||||
self.transactions = transactions
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
self.total = try container.decode(Int.self, forKey: .total)
|
||||
self.transactions = try container.decode([Transaction].self, forKey: .transactions)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
try container.encode(total, forKey: .total)
|
||||
try container.encode(transactions, forKey: .transactions)
|
||||
}
|
||||
|
||||
public func toMap() -> [String: Any] {
|
||||
return [
|
||||
"total": total as Any,
|
||||
"transactions": transactions.map { $0.toMap() } as Any
|
||||
]
|
||||
}
|
||||
|
||||
public static func from(map: [String: Any] ) -> TransactionList {
|
||||
return TransactionList(
|
||||
total: map["total"] as! Int,
|
||||
transactions: (map["transactions"] as! [[String: Any]]).map { Transaction.from(map: $0) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ let document = try await databases.createDocument(
|
||||
"age": 30,
|
||||
"isAdmin": false
|
||||
],
|
||||
permissions: ["read("any")"] // optional
|
||||
permissions: ["read("any")"], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let databases = Databases(client)
|
||||
let documentList = try await databases.createDocuments(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
documents: []
|
||||
documents: [],
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let databases = Databases(client)
|
||||
|
||||
let transaction = try await databases.createOperations(
|
||||
transactionId: "<TRANSACTION_ID>",
|
||||
operations: [
|
||||
{
|
||||
"action": "create",
|
||||
"databaseId": "<DATABASE_ID>",
|
||||
"collectionId": "<COLLECTION_ID>",
|
||||
"documentId": "<DOCUMENT_ID>",
|
||||
"data": {
|
||||
"name": "Walter O'Brien"
|
||||
}
|
||||
}
|
||||
] // optional
|
||||
)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let databases = Databases(client)
|
||||
|
||||
let transaction = try await databases.createTransaction(
|
||||
ttl: 60 // optional
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ let document = try await databases.decrementDocumentAttribute(
|
||||
documentId: "<DOCUMENT_ID>",
|
||||
attribute: "",
|
||||
value: 0, // optional
|
||||
min: 0 // optional
|
||||
min: 0, // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let databases = Databases(client)
|
||||
let result = try await databases.deleteDocument(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
documentId: "<DOCUMENT_ID>"
|
||||
documentId: "<DOCUMENT_ID>",
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let databases = Databases(client)
|
||||
let documentList = try await databases.deleteDocuments(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let databases = Databases(client)
|
||||
|
||||
let result = try await databases.deleteTransaction(
|
||||
transactionId: "<TRANSACTION_ID>"
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ let document = try await databases.getDocument(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
documentId: "<DOCUMENT_ID>",
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let databases = Databases(client)
|
||||
|
||||
let transaction = try await databases.getTransaction(
|
||||
transactionId: "<TRANSACTION_ID>"
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ let document = try await databases.incrementDocumentAttribute(
|
||||
documentId: "<DOCUMENT_ID>",
|
||||
attribute: "",
|
||||
value: 0, // optional
|
||||
max: 0 // optional
|
||||
max: 0, // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let databases = Databases(client)
|
||||
let documentList = try await databases.listDocuments(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let databases = Databases(client)
|
||||
|
||||
let transactionList = try await databases.listTransactions(
|
||||
queries: [] // optional
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ let document = try await databases.updateDocument(
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
documentId: "<DOCUMENT_ID>",
|
||||
data: [:], // optional
|
||||
permissions: ["read("any")"] // optional
|
||||
permissions: ["read("any")"], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ let documentList = try await databases.updateDocuments(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
data: [:], // optional
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let databases = Databases(client)
|
||||
|
||||
let transaction = try await databases.updateTransaction(
|
||||
transactionId: "<TRANSACTION_ID>",
|
||||
commit: false, // optional
|
||||
rollback: false // optional
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ let document = try await databases.upsertDocument(
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
documentId: "<DOCUMENT_ID>",
|
||||
data: [:],
|
||||
permissions: ["read("any")"] // optional
|
||||
permissions: ["read("any")"], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let databases = Databases(client)
|
||||
let documentList = try await databases.upsertDocuments(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
collectionId: "<COLLECTION_ID>",
|
||||
documents: []
|
||||
documents: [],
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ let message = try await messaging.createPush(
|
||||
targets: [], // optional
|
||||
data: [:], // optional
|
||||
action: "<ACTION>", // optional
|
||||
image: "[ID1:ID2]", // optional
|
||||
image: "<ID1:ID2>", // optional
|
||||
icon: "<ICON>", // optional
|
||||
sound: "<SOUND>", // optional
|
||||
color: "<COLOR>", // optional
|
||||
|
||||
@@ -17,7 +17,7 @@ let message = try await messaging.updatePush(
|
||||
body: "<BODY>", // optional
|
||||
data: [:], // optional
|
||||
action: "<ACTION>", // optional
|
||||
image: "[ID1:ID2]", // optional
|
||||
image: "<ID1:ID2>", // optional
|
||||
icon: "<ICON>", // optional
|
||||
sound: "<SOUND>", // optional
|
||||
color: "<COLOR>", // optional
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let tablesDB = TablesDB(client)
|
||||
|
||||
let transaction = try await tablesDB.createOperations(
|
||||
transactionId: "<TRANSACTION_ID>",
|
||||
operations: [
|
||||
{
|
||||
"action": "create",
|
||||
"databaseId": "<DATABASE_ID>",
|
||||
"tableId": "<TABLE_ID>",
|
||||
"rowId": "<ROW_ID>",
|
||||
"data": {
|
||||
"name": "Walter O'Brien"
|
||||
}
|
||||
}
|
||||
] // optional
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@ let row = try await tablesDB.createRow(
|
||||
"age": 30,
|
||||
"isAdmin": false
|
||||
],
|
||||
permissions: ["read("any")"] // optional
|
||||
permissions: ["read("any")"], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let tablesDB = TablesDB(client)
|
||||
let rowList = try await tablesDB.createRows(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
rows: []
|
||||
rows: [],
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let tablesDB = TablesDB(client)
|
||||
|
||||
let transaction = try await tablesDB.createTransaction(
|
||||
ttl: 60 // optional
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ let row = try await tablesDB.decrementRowColumn(
|
||||
rowId: "<ROW_ID>",
|
||||
column: "",
|
||||
value: 0, // optional
|
||||
min: 0 // optional
|
||||
min: 0, // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let tablesDB = TablesDB(client)
|
||||
let result = try await tablesDB.deleteRow(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
rowId: "<ROW_ID>"
|
||||
rowId: "<ROW_ID>",
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let tablesDB = TablesDB(client)
|
||||
let rowList = try await tablesDB.deleteRows(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let tablesDB = TablesDB(client)
|
||||
|
||||
let result = try await tablesDB.deleteTransaction(
|
||||
transactionId: "<TRANSACTION_ID>"
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ let row = try await tablesDB.getRow(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
rowId: "<ROW_ID>",
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let tablesDB = TablesDB(client)
|
||||
|
||||
let transaction = try await tablesDB.getTransaction(
|
||||
transactionId: "<TRANSACTION_ID>"
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ let row = try await tablesDB.incrementRowColumn(
|
||||
rowId: "<ROW_ID>",
|
||||
column: "",
|
||||
value: 0, // optional
|
||||
max: 0 // optional
|
||||
max: 0, // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let tablesDB = TablesDB(client)
|
||||
let rowList = try await tablesDB.listRows(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let tablesDB = TablesDB(client)
|
||||
|
||||
let transactionList = try await tablesDB.listTransactions(
|
||||
queries: [] // optional
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ let row = try await tablesDB.updateRow(
|
||||
tableId: "<TABLE_ID>",
|
||||
rowId: "<ROW_ID>",
|
||||
data: [:], // optional
|
||||
permissions: ["read("any")"] // optional
|
||||
permissions: ["read("any")"], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ let rowList = try await tablesDB.updateRows(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
data: [:], // optional
|
||||
queries: [] // optional
|
||||
queries: [], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
.setKey("<YOUR_API_KEY>") // Your secret API key
|
||||
|
||||
let tablesDB = TablesDB(client)
|
||||
|
||||
let transaction = try await tablesDB.updateTransaction(
|
||||
transactionId: "<TRANSACTION_ID>",
|
||||
commit: false, // optional
|
||||
rollback: false // optional
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ let row = try await tablesDB.upsertRow(
|
||||
tableId: "<TABLE_ID>",
|
||||
rowId: "<ROW_ID>",
|
||||
data: [:], // optional
|
||||
permissions: ["read("any")"] // optional
|
||||
permissions: ["read("any")"], // optional
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let tablesDB = TablesDB(client)
|
||||
let rowList = try await tablesDB.upsertRows(
|
||||
databaseId: "<DATABASE_ID>",
|
||||
tableId: "<TABLE_ID>",
|
||||
rows: []
|
||||
rows: [],
|
||||
transactionId: "<TRANSACTION_ID>" // optional
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user