@@ -97,18 +97,17 @@ export class Databases extends Service {
97
97
}
98
98
99
99
/**
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.
104
102
*
105
103
* @param {string } databaseId
106
104
* @param {string } collectionId
107
- * @param {object[] } documents
105
+ * @param {string } documentId
106
+ * @param {string[] } queries
108
107
* @throws {AppwriteException }
109
108
* @returns {Promise }
110
109
*/
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 > {
112
111
if ( typeof databaseId === 'undefined' ) {
113
112
throw new AppwriteException ( 'Missing required parameter: "databaseId"' ) ;
114
113
}
@@ -117,35 +116,37 @@ export class Databases extends Service {
117
116
throw new AppwriteException ( 'Missing required parameter: "collectionId"' ) ;
118
117
}
119
118
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 "' ) ;
122
121
}
123
122
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 ) ;
125
124
const payload : Payload = { } ;
126
125
127
- if ( typeof documents !== 'undefined' ) {
128
- payload [ 'documents ' ] = documents ;
126
+ if ( typeof queries !== 'undefined' ) {
127
+ payload [ 'queries ' ] = queries ;
129
128
}
130
129
131
130
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 , {
134
132
} , payload ) ;
135
133
}
136
134
137
135
/**
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.
140
140
*
141
141
* @param {string } databaseId
142
142
* @param {string } collectionId
143
143
* @param {string } documentId
144
- * @param {string[] } queries
144
+ * @param {object } data
145
+ * @param {string[] } permissions
145
146
* @throws {AppwriteException }
146
147
* @returns {Promise }
147
148
*/
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 > {
149
150
if ( typeof databaseId === 'undefined' ) {
150
151
throw new AppwriteException ( 'Missing required parameter: "databaseId"' ) ;
151
152
}
@@ -158,15 +159,24 @@ export class Databases extends Service {
158
159
throw new AppwriteException ( 'Missing required parameter: "documentId"' ) ;
159
160
}
160
161
162
+ if ( typeof data === 'undefined' ) {
163
+ throw new AppwriteException ( 'Missing required parameter: "data"' ) ;
164
+ }
165
+
161
166
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' . replace ( '{databaseId}' , databaseId ) . replace ( '{collectionId}' , collectionId ) . replace ( '{documentId}' , documentId ) ;
162
167
const payload : Payload = { } ;
163
168
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 ;
166
175
}
167
176
168
177
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' ,
170
180
} , payload ) ;
171
181
}
172
182
0 commit comments