@@ -1580,7 +1580,6 @@ open class Databases: Service {
15801580 /// collection resource using either a [server
15811581 /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
15821582 /// API or directly from your database console.
1583- ///
15841583 ///
15851584 /// @param String databaseId
15861585 /// @param String collectionId
@@ -1630,7 +1629,6 @@ open class Databases: Service {
16301629 /// collection resource using either a [server
16311630 /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
16321631 /// API or directly from your database console.
1633- ///
16341632 ///
16351633 /// @param String databaseId
16361634 /// @param String collectionId
@@ -1657,6 +1655,282 @@ open class Databases: Service {
16571655 )
16581656 }
16591657
1658+ ///
1659+ /// Create new Documents. Before using this route, you should create a new
1660+ /// collection resource using either a [server
1661+ /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1662+ /// API or directly from your database console.
1663+ ///
1664+ ///
1665+ /// @param String databaseId
1666+ /// @param String collectionId
1667+ /// @param [Any] documents
1668+ /// @throws Exception
1669+ /// @return array
1670+ ///
1671+ open func createDocuments< T> (
1672+ databaseId: String ,
1673+ collectionId: String ,
1674+ documents: [ Any ] ,
1675+ nestedType: T . Type
1676+ ) async throws -> AppwriteModels . DocumentList < T > {
1677+ let apiPath : String = " /databases/{databaseId}/collections/{collectionId}/documents "
1678+ . replacingOccurrences ( of: " {databaseId} " , with: databaseId)
1679+ . replacingOccurrences ( of: " {collectionId} " , with: collectionId)
1680+
1681+ let apiParams : [ String : Any ? ] = [
1682+ " documents " : documents
1683+ ]
1684+
1685+ let apiHeaders : [ String : String ] = [
1686+ " content-type " : " application/json "
1687+ ]
1688+
1689+ let converter : ( Any ) -> AppwriteModels . DocumentList < T > = { response in
1690+ return AppwriteModels . DocumentList. from ( map: response as! [ String : Any ] )
1691+ }
1692+
1693+ return try await client. call (
1694+ method: " POST " ,
1695+ path: apiPath,
1696+ headers: apiHeaders,
1697+ params: apiParams,
1698+ converter: converter
1699+ )
1700+ }
1701+
1702+ ///
1703+ /// Create new Documents. Before using this route, you should create a new
1704+ /// collection resource using either a [server
1705+ /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1706+ /// API or directly from your database console.
1707+ ///
1708+ ///
1709+ /// @param String databaseId
1710+ /// @param String collectionId
1711+ /// @param [Any] documents
1712+ /// @throws Exception
1713+ /// @return array
1714+ ///
1715+ open func createDocuments(
1716+ databaseId: String ,
1717+ collectionId: String ,
1718+ documents: [ Any ]
1719+ ) async throws -> AppwriteModels . DocumentList < [ String : AnyCodable ] > {
1720+ return try await createDocuments (
1721+ databaseId: databaseId,
1722+ collectionId: collectionId,
1723+ documents: documents,
1724+ nestedType: [ String : AnyCodable ] . self
1725+ )
1726+ }
1727+
1728+ ///
1729+ /// Create or update Documents. Before using this route, you should create a
1730+ /// new collection resource using either a [server
1731+ /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1732+ /// API or directly from your database console.
1733+ ///
1734+ ///
1735+ /// @param String databaseId
1736+ /// @param String collectionId
1737+ /// @param [Any] documents
1738+ /// @throws Exception
1739+ /// @return array
1740+ ///
1741+ open func upsertDocuments< T> (
1742+ databaseId: String ,
1743+ collectionId: String ,
1744+ documents: [ Any ] ? = nil ,
1745+ nestedType: T . Type
1746+ ) async throws -> AppwriteModels . DocumentList < T > {
1747+ let apiPath : String = " /databases/{databaseId}/collections/{collectionId}/documents "
1748+ . replacingOccurrences ( of: " {databaseId} " , with: databaseId)
1749+ . replacingOccurrences ( of: " {collectionId} " , with: collectionId)
1750+
1751+ let apiParams : [ String : Any ? ] = [
1752+ " documents " : documents
1753+ ]
1754+
1755+ let apiHeaders : [ String : String ] = [
1756+ " content-type " : " application/json "
1757+ ]
1758+
1759+ let converter : ( Any ) -> AppwriteModels . DocumentList < T > = { response in
1760+ return AppwriteModels . DocumentList. from ( map: response as! [ String : Any ] )
1761+ }
1762+
1763+ return try await client. call (
1764+ method: " PUT " ,
1765+ path: apiPath,
1766+ headers: apiHeaders,
1767+ params: apiParams,
1768+ converter: converter
1769+ )
1770+ }
1771+
1772+ ///
1773+ /// Create or update Documents. Before using this route, you should create a
1774+ /// new collection resource using either a [server
1775+ /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1776+ /// API or directly from your database console.
1777+ ///
1778+ ///
1779+ /// @param String databaseId
1780+ /// @param String collectionId
1781+ /// @param [Any] documents
1782+ /// @throws Exception
1783+ /// @return array
1784+ ///
1785+ open func upsertDocuments(
1786+ databaseId: String ,
1787+ collectionId: String ,
1788+ documents: [ Any ] ? = nil
1789+ ) async throws -> AppwriteModels . DocumentList < [ String : AnyCodable ] > {
1790+ return try await upsertDocuments (
1791+ databaseId: databaseId,
1792+ collectionId: collectionId,
1793+ documents: documents,
1794+ nestedType: [ String : AnyCodable ] . self
1795+ )
1796+ }
1797+
1798+ ///
1799+ /// Update all documents that match your queries, if no queries are submitted
1800+ /// then all documents are updated. You can pass only specific fields to be
1801+ /// updated.
1802+ ///
1803+ /// @param String databaseId
1804+ /// @param String collectionId
1805+ /// @param Any data
1806+ /// @param [String] queries
1807+ /// @throws Exception
1808+ /// @return array
1809+ ///
1810+ open func updateDocuments< T> (
1811+ databaseId: String ,
1812+ collectionId: String ,
1813+ data: Any ? = nil ,
1814+ queries: [ String ] ? = nil ,
1815+ nestedType: T . Type
1816+ ) async throws -> AppwriteModels . DocumentList < T > {
1817+ let apiPath : String = " /databases/{databaseId}/collections/{collectionId}/documents "
1818+ . replacingOccurrences ( of: " {databaseId} " , with: databaseId)
1819+ . replacingOccurrences ( of: " {collectionId} " , with: collectionId)
1820+
1821+ let apiParams : [ String : Any ? ] = [
1822+ " data " : data,
1823+ " queries " : queries
1824+ ]
1825+
1826+ let apiHeaders : [ String : String ] = [
1827+ " content-type " : " application/json "
1828+ ]
1829+
1830+ let converter : ( Any ) -> AppwriteModels . DocumentList < T > = { response in
1831+ return AppwriteModels . DocumentList. from ( map: response as! [ String : Any ] )
1832+ }
1833+
1834+ return try await client. call (
1835+ method: " PATCH " ,
1836+ path: apiPath,
1837+ headers: apiHeaders,
1838+ params: apiParams,
1839+ converter: converter
1840+ )
1841+ }
1842+
1843+ ///
1844+ /// Update all documents that match your queries, if no queries are submitted
1845+ /// then all documents are updated. You can pass only specific fields to be
1846+ /// updated.
1847+ ///
1848+ /// @param String databaseId
1849+ /// @param String collectionId
1850+ /// @param Any data
1851+ /// @param [String] queries
1852+ /// @throws Exception
1853+ /// @return array
1854+ ///
1855+ open func updateDocuments(
1856+ databaseId: String ,
1857+ collectionId: String ,
1858+ data: Any ? = nil ,
1859+ queries: [ String ] ? = nil
1860+ ) async throws -> AppwriteModels . DocumentList < [ String : AnyCodable ] > {
1861+ return try await updateDocuments (
1862+ databaseId: databaseId,
1863+ collectionId: collectionId,
1864+ data: data,
1865+ queries: queries,
1866+ nestedType: [ String : AnyCodable ] . self
1867+ )
1868+ }
1869+
1870+ ///
1871+ /// Bulk delete documents using queries, if no queries are passed then all
1872+ /// documents are deleted.
1873+ ///
1874+ /// @param String databaseId
1875+ /// @param String collectionId
1876+ /// @param [String] queries
1877+ /// @throws Exception
1878+ /// @return array
1879+ ///
1880+ open func deleteDocuments< T> (
1881+ databaseId: String ,
1882+ collectionId: String ,
1883+ queries: [ String ] ? = nil ,
1884+ nestedType: T . Type
1885+ ) async throws -> AppwriteModels . DocumentList < T > {
1886+ let apiPath : String = " /databases/{databaseId}/collections/{collectionId}/documents "
1887+ . replacingOccurrences ( of: " {databaseId} " , with: databaseId)
1888+ . replacingOccurrences ( of: " {collectionId} " , with: collectionId)
1889+
1890+ let apiParams : [ String : Any ? ] = [
1891+ " queries " : queries
1892+ ]
1893+
1894+ let apiHeaders : [ String : String ] = [
1895+ " content-type " : " application/json "
1896+ ]
1897+
1898+ let converter : ( Any ) -> AppwriteModels . DocumentList < T > = { response in
1899+ return AppwriteModels . DocumentList. from ( map: response as! [ String : Any ] )
1900+ }
1901+
1902+ return try await client. call (
1903+ method: " DELETE " ,
1904+ path: apiPath,
1905+ headers: apiHeaders,
1906+ params: apiParams,
1907+ converter: converter
1908+ )
1909+ }
1910+
1911+ ///
1912+ /// Bulk delete documents using queries, if no queries are passed then all
1913+ /// documents are deleted.
1914+ ///
1915+ /// @param String databaseId
1916+ /// @param String collectionId
1917+ /// @param [String] queries
1918+ /// @throws Exception
1919+ /// @return array
1920+ ///
1921+ open func deleteDocuments(
1922+ databaseId: String ,
1923+ collectionId: String ,
1924+ queries: [ String ] ? = nil
1925+ ) async throws -> AppwriteModels . DocumentList < [ String : AnyCodable ] > {
1926+ return try await deleteDocuments (
1927+ databaseId: databaseId,
1928+ collectionId: collectionId,
1929+ queries: queries,
1930+ nestedType: [ String : AnyCodable ] . self
1931+ )
1932+ }
1933+
16601934 ///
16611935 /// Get a document by its unique ID. This endpoint response returns a JSON
16621936 /// object with the document data.
0 commit comments