@@ -1656,6 +1656,10 @@ open class Databases: Service {
16561656 }
16571657
16581658 ///
1659+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
1660+ /// yet officially supported. It may be subject to breaking changes or removal
1661+ /// in future versions.
1662+ ///
16591663 /// Create new Documents. Before using this route, you should create a new
16601664 /// collection resource using either a [server
16611665 /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
@@ -1699,6 +1703,10 @@ open class Databases: Service {
16991703 }
17001704
17011705 ///
1706+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
1707+ /// yet officially supported. It may be subject to breaking changes or removal
1708+ /// in future versions.
1709+ ///
17021710 /// Create new Documents. Before using this route, you should create a new
17031711 /// collection resource using either a [server
17041712 /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
@@ -1724,6 +1732,10 @@ open class Databases: Service {
17241732 }
17251733
17261734 ///
1735+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
1736+ /// yet officially supported. It may be subject to breaking changes or removal
1737+ /// in future versions.
1738+ ///
17271739 /// Create or update Documents. Before using this route, you should create a
17281740 /// new collection resource using either a [server
17291741 /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
@@ -1768,6 +1780,10 @@ open class Databases: Service {
17681780 }
17691781
17701782 ///
1783+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
1784+ /// yet officially supported. It may be subject to breaking changes or removal
1785+ /// in future versions.
1786+ ///
17711787 /// Create or update Documents. Before using this route, you should create a
17721788 /// new collection resource using either a [server
17731789 /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
@@ -1866,6 +1882,10 @@ open class Databases: Service {
18661882 }
18671883
18681884 ///
1885+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
1886+ /// yet officially supported. It may be subject to breaking changes or removal
1887+ /// in future versions.
1888+ ///
18691889 /// Bulk delete documents using queries, if no queries are passed then all
18701890 /// documents are deleted.
18711891 ///
@@ -1907,6 +1927,10 @@ open class Databases: Service {
19071927 }
19081928
19091929 ///
1930+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
1931+ /// yet officially supported. It may be subject to breaking changes or removal
1932+ /// in future versions.
1933+ ///
19101934 /// Bulk delete documents using queries, if no queries are passed then all
19111935 /// documents are deleted.
19121936 ///
@@ -1997,6 +2021,94 @@ open class Databases: Service {
19972021 )
19982022 }
19992023
2024+ ///
2025+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
2026+ /// yet officially supported. It may be subject to breaking changes or removal
2027+ /// in future versions.
2028+ ///
2029+ /// Create or update a Document. Before using this route, you should create a
2030+ /// new collection resource using either a [server
2031+ /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2032+ /// API or directly from your database console.
2033+ ///
2034+ /// @param String databaseId
2035+ /// @param String collectionId
2036+ /// @param String documentId
2037+ /// @param Any data
2038+ /// @param [String] permissions
2039+ /// @throws Exception
2040+ /// @return array
2041+ ///
2042+ open func upsertDocument< T> (
2043+ databaseId: String ,
2044+ collectionId: String ,
2045+ documentId: String ,
2046+ data: Any ,
2047+ permissions: [ String ] ? = nil ,
2048+ nestedType: T . Type
2049+ ) async throws -> AppwriteModels . Document < T > {
2050+ let apiPath : String = " /databases/{databaseId}/collections/{collectionId}/documents/{documentId} "
2051+ . replacingOccurrences ( of: " {databaseId} " , with: databaseId)
2052+ . replacingOccurrences ( of: " {collectionId} " , with: collectionId)
2053+ . replacingOccurrences ( of: " {documentId} " , with: documentId)
2054+
2055+ let apiParams : [ String : Any ? ] = [
2056+ " data " : data,
2057+ " permissions " : permissions
2058+ ]
2059+
2060+ let apiHeaders : [ String : String ] = [
2061+ " content-type " : " application/json "
2062+ ]
2063+
2064+ let converter : ( Any ) -> AppwriteModels . Document < T > = { response in
2065+ return AppwriteModels . Document. from ( map: response as! [ String : Any ] )
2066+ }
2067+
2068+ return try await client. call (
2069+ method: " PUT " ,
2070+ path: apiPath,
2071+ headers: apiHeaders,
2072+ params: apiParams,
2073+ converter: converter
2074+ )
2075+ }
2076+
2077+ ///
2078+ /// **WARNING: Experimental Feature** - This endpoint is experimental and not
2079+ /// yet officially supported. It may be subject to breaking changes or removal
2080+ /// in future versions.
2081+ ///
2082+ /// Create or update a Document. Before using this route, you should create a
2083+ /// new collection resource using either a [server
2084+ /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2085+ /// API or directly from your database console.
2086+ ///
2087+ /// @param String databaseId
2088+ /// @param String collectionId
2089+ /// @param String documentId
2090+ /// @param Any data
2091+ /// @param [String] permissions
2092+ /// @throws Exception
2093+ /// @return array
2094+ ///
2095+ open func upsertDocument(
2096+ databaseId: String ,
2097+ collectionId: String ,
2098+ documentId: String ,
2099+ data: Any ,
2100+ permissions: [ String ] ? = nil
2101+ ) async throws -> AppwriteModels . Document < [ String : AnyCodable ] > {
2102+ return try await upsertDocument (
2103+ databaseId: databaseId,
2104+ collectionId: collectionId,
2105+ documentId: documentId,
2106+ data: data,
2107+ permissions: permissions,
2108+ nestedType: [ String : AnyCodable ] . self
2109+ )
2110+ }
2111+
20002112 ///
20012113 /// Update a document by its unique ID. Using the patch method you can pass
20022114 /// only specific fields that will get updated.
0 commit comments