@@ -256,4 +256,96 @@ export class Databases extends Service {
256256 'content-type' : 'application/json' ,
257257 } , payload ) ;
258258 }
259+
260+ /**
261+ * Decrement a specific attribute of a document by a given value.
262+ *
263+ * @param {string } databaseId
264+ * @param {string } collectionId
265+ * @param {string } documentId
266+ * @param {string } attribute
267+ * @param {number } value
268+ * @param {number } min
269+ * @throws {AppwriteException }
270+ * @returns {Promise }
271+ */
272+ decrementDocumentAttribute < Document extends Models . Document > ( databaseId : string , collectionId : string , documentId : string , attribute : string , value ?: number , min ?: number ) : Promise < Document > {
273+ if ( typeof databaseId === 'undefined' ) {
274+ throw new AppwriteException ( 'Missing required parameter: "databaseId"' ) ;
275+ }
276+
277+ if ( typeof collectionId === 'undefined' ) {
278+ throw new AppwriteException ( 'Missing required parameter: "collectionId"' ) ;
279+ }
280+
281+ if ( typeof documentId === 'undefined' ) {
282+ throw new AppwriteException ( 'Missing required parameter: "documentId"' ) ;
283+ }
284+
285+ if ( typeof attribute === 'undefined' ) {
286+ throw new AppwriteException ( 'Missing required parameter: "attribute"' ) ;
287+ }
288+
289+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' . replace ( '{databaseId}' , databaseId ) . replace ( '{collectionId}' , collectionId ) . replace ( '{documentId}' , documentId ) . replace ( '{attribute}' , attribute ) ;
290+ const payload : Payload = { } ;
291+
292+ if ( typeof value !== 'undefined' ) {
293+ payload [ 'value' ] = value ;
294+ }
295+
296+ if ( typeof min !== 'undefined' ) {
297+ payload [ 'min' ] = min ;
298+ }
299+
300+ const uri = new URL ( this . client . config . endpoint + apiPath ) ;
301+ return this . client . call ( 'patch' , uri , {
302+ 'content-type' : 'application/json' ,
303+ } , payload ) ;
304+ }
305+
306+ /**
307+ * Increment a specific attribute of a document by a given value.
308+ *
309+ * @param {string } databaseId
310+ * @param {string } collectionId
311+ * @param {string } documentId
312+ * @param {string } attribute
313+ * @param {number } value
314+ * @param {number } max
315+ * @throws {AppwriteException }
316+ * @returns {Promise }
317+ */
318+ incrementDocumentAttribute < Document extends Models . Document > ( databaseId : string , collectionId : string , documentId : string , attribute : string , value ?: number , max ?: number ) : Promise < Document > {
319+ if ( typeof databaseId === 'undefined' ) {
320+ throw new AppwriteException ( 'Missing required parameter: "databaseId"' ) ;
321+ }
322+
323+ if ( typeof collectionId === 'undefined' ) {
324+ throw new AppwriteException ( 'Missing required parameter: "collectionId"' ) ;
325+ }
326+
327+ if ( typeof documentId === 'undefined' ) {
328+ throw new AppwriteException ( 'Missing required parameter: "documentId"' ) ;
329+ }
330+
331+ if ( typeof attribute === 'undefined' ) {
332+ throw new AppwriteException ( 'Missing required parameter: "attribute"' ) ;
333+ }
334+
335+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' . replace ( '{databaseId}' , databaseId ) . replace ( '{collectionId}' , collectionId ) . replace ( '{documentId}' , documentId ) . replace ( '{attribute}' , attribute ) ;
336+ const payload : Payload = { } ;
337+
338+ if ( typeof value !== 'undefined' ) {
339+ payload [ 'value' ] = value ;
340+ }
341+
342+ if ( typeof max !== 'undefined' ) {
343+ payload [ 'max' ] = max ;
344+ }
345+
346+ const uri = new URL ( this . client . config . endpoint + apiPath ) ;
347+ return this . client . call ( 'patch' , uri , {
348+ 'content-type' : 'application/json' ,
349+ } , payload ) ;
350+ }
259351} ;
0 commit comments