@@ -97,18 +97,17 @@ export class Databases extends Service {
9797 }
9898
9999 /**
100- * Create new Documents. Before using this route, you should create a new
101- * collection resource using either a [server
102- * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
103- * API or directly from your database console.
100+ * Get a document by its unique ID. This endpoint response returns a JSON
101+ * object with the document data.
104102 *
105103 * @param {string } databaseId
106104 * @param {string } collectionId
107- * @param {object[] } documents
105+ * @param {string } documentId
106+ * @param {string[] } queries
108107 * @throws {AppwriteException }
109108 * @returns {Promise }
110109 */
111- createDocuments < Document extends Models . Document > ( databaseId : string , collectionId : string , documents : object [ ] ) : Promise < Models . DocumentList < Document > > {
110+ getDocument < Document extends Models . Document > ( databaseId : string , collectionId : string , documentId : string , queries ?: string [ ] ) : Promise < Document > {
112111 if ( typeof databaseId === 'undefined' ) {
113112 throw new AppwriteException ( 'Missing required parameter: "databaseId"' ) ;
114113 }
@@ -117,35 +116,37 @@ export class Databases extends Service {
117116 throw new AppwriteException ( 'Missing required parameter: "collectionId"' ) ;
118117 }
119118
120- if ( typeof documents === 'undefined' ) {
121- throw new AppwriteException ( 'Missing required parameter: "documents "' ) ;
119+ if ( typeof documentId === 'undefined' ) {
120+ throw new AppwriteException ( 'Missing required parameter: "documentId "' ) ;
122121 }
123122
124- const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents' . replace ( '{databaseId}' , databaseId ) . replace ( '{collectionId}' , collectionId ) ;
123+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ' . replace ( '{databaseId}' , databaseId ) . replace ( '{collectionId}' , collectionId ) . replace ( '{documentId}' , documentId ) ;
125124 const payload : Payload = { } ;
126125
127- if ( typeof documents !== 'undefined' ) {
128- payload [ 'documents ' ] = documents ;
126+ if ( typeof queries !== 'undefined' ) {
127+ payload [ 'queries ' ] = queries ;
129128 }
130129
131130 const uri = new URL ( this . client . config . endpoint + apiPath ) ;
132- return this . client . call ( 'post' , uri , {
133- 'content-type' : 'application/json' ,
131+ return this . client . call ( 'get' , uri , {
134132 } , payload ) ;
135133 }
136134
137135 /**
138- * Get a document by its unique ID. This endpoint response returns a JSON
139- * object with the document data.
136+ * Create or update a Document. Before using this route, you should create a
137+ * new collection resource using either a [server
138+ * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
139+ * API or directly from your database console.
140140 *
141141 * @param {string } databaseId
142142 * @param {string } collectionId
143143 * @param {string } documentId
144- * @param {string[] } queries
144+ * @param {object } data
145+ * @param {string[] } permissions
145146 * @throws {AppwriteException }
146147 * @returns {Promise }
147148 */
148- getDocument < Document extends Models . Document > ( databaseId : string , collectionId : string , documentId : string , queries ?: string [ ] ) : Promise < Document > {
149+ upsertDocument < Document extends Models . Document > ( databaseId : string , collectionId : string , documentId : string , data : object , permissions ?: string [ ] ) : Promise < Document > {
149150 if ( typeof databaseId === 'undefined' ) {
150151 throw new AppwriteException ( 'Missing required parameter: "databaseId"' ) ;
151152 }
@@ -158,15 +159,24 @@ export class Databases extends Service {
158159 throw new AppwriteException ( 'Missing required parameter: "documentId"' ) ;
159160 }
160161
162+ if ( typeof data === 'undefined' ) {
163+ throw new AppwriteException ( 'Missing required parameter: "data"' ) ;
164+ }
165+
161166 const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' . replace ( '{databaseId}' , databaseId ) . replace ( '{collectionId}' , collectionId ) . replace ( '{documentId}' , documentId ) ;
162167 const payload : Payload = { } ;
163168
164- if ( typeof queries !== 'undefined' ) {
165- payload [ 'queries' ] = queries ;
169+ if ( typeof data !== 'undefined' ) {
170+ payload [ 'data' ] = data ;
171+ }
172+
173+ if ( typeof permissions !== 'undefined' ) {
174+ payload [ 'permissions' ] = permissions ;
166175 }
167176
168177 const uri = new URL ( this . client . config . endpoint + apiPath ) ;
169- return this . client . call ( 'get' , uri , {
178+ return this . client . call ( 'put' , uri , {
179+ 'content-type' : 'application/json' ,
170180 } , payload ) ;
171181 }
172182
0 commit comments