@@ -443,4 +443,180 @@ class Databases(client: Client) : Service(client) {
443443 }
444444
445445
446+ /* *
447+ * Decrement a specific attribute of a document by a given value.
448+ *
449+ * @param databaseId Database ID.
450+ * @param collectionId Collection ID.
451+ * @param documentId Document ID.
452+ * @param attribute Attribute key.
453+ * @param value Value to increment the attribute by. The value must be a number.
454+ * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
455+ * @return [io.appwrite.models.Document<T>]
456+ */
457+ @Deprecated(
458+ message = " This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead." ,
459+ replaceWith = ReplaceWith (" io.appwrite.services.TablesDb.decrementRowColumn" ),
460+ since = " 1.8.0"
461+ )
462+ @JvmOverloads
463+ suspend fun <T > decrementDocumentAttribute (
464+ databaseId : String ,
465+ collectionId : String ,
466+ documentId : String ,
467+ attribute : String ,
468+ value : Double? = null,
469+ min : Double? = null,
470+ nestedType : Class <T >,
471+ ): io.appwrite.models.Document <T > {
472+ val apiPath = " /databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement"
473+ .replace(" {databaseId}" , databaseId)
474+ .replace(" {collectionId}" , collectionId)
475+ .replace(" {documentId}" , documentId)
476+ .replace(" {attribute}" , attribute)
477+
478+ val apiParams = mutableMapOf<String , Any ?>(
479+ " value" to value,
480+ " min" to min,
481+ )
482+ val apiHeaders = mutableMapOf<String , String >(
483+ " content-type" to " application/json" ,
484+ )
485+ val converter: (Any ) -> io.appwrite.models.Document <T > = {
486+ @Suppress(" UNCHECKED_CAST" )
487+ io.appwrite.models.Document .from(map = it as Map <String , Any >, nestedType)
488+ }
489+ return client.call(
490+ " PATCH" ,
491+ apiPath,
492+ apiHeaders,
493+ apiParams,
494+ responseType = classOf(),
495+ converter,
496+ )
497+ }
498+
499+ /* *
500+ * Decrement a specific attribute of a document by a given value.
501+ *
502+ * @param databaseId Database ID.
503+ * @param collectionId Collection ID.
504+ * @param documentId Document ID.
505+ * @param attribute Attribute key.
506+ * @param value Value to increment the attribute by. The value must be a number.
507+ * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
508+ * @return [io.appwrite.models.Document<T>]
509+ */
510+ @Deprecated(
511+ message = " This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead." ,
512+ replaceWith = ReplaceWith (" io.appwrite.services.TablesDb.decrementRowColumn" ),
513+ since = " 1.8.0"
514+ )
515+ @JvmOverloads
516+ @Throws(AppwriteException ::class )
517+ suspend fun decrementDocumentAttribute (
518+ databaseId : String ,
519+ collectionId : String ,
520+ documentId : String ,
521+ attribute : String ,
522+ value : Double? = null,
523+ min : Double? = null,
524+ ): io.appwrite.models.Document <Map <String , Any >> = decrementDocumentAttribute(
525+ databaseId,
526+ collectionId,
527+ documentId,
528+ attribute,
529+ value,
530+ min,
531+ nestedType = classOf(),
532+ )
533+
534+ /* *
535+ * Increment a specific attribute of a document by a given value.
536+ *
537+ * @param databaseId Database ID.
538+ * @param collectionId Collection ID.
539+ * @param documentId Document ID.
540+ * @param attribute Attribute key.
541+ * @param value Value to increment the attribute by. The value must be a number.
542+ * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
543+ * @return [io.appwrite.models.Document<T>]
544+ */
545+ @Deprecated(
546+ message = " This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead." ,
547+ replaceWith = ReplaceWith (" io.appwrite.services.TablesDb.incrementRowColumn" ),
548+ since = " 1.8.0"
549+ )
550+ @JvmOverloads
551+ suspend fun <T > incrementDocumentAttribute (
552+ databaseId : String ,
553+ collectionId : String ,
554+ documentId : String ,
555+ attribute : String ,
556+ value : Double? = null,
557+ max : Double? = null,
558+ nestedType : Class <T >,
559+ ): io.appwrite.models.Document <T > {
560+ val apiPath = " /databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment"
561+ .replace(" {databaseId}" , databaseId)
562+ .replace(" {collectionId}" , collectionId)
563+ .replace(" {documentId}" , documentId)
564+ .replace(" {attribute}" , attribute)
565+
566+ val apiParams = mutableMapOf<String , Any ?>(
567+ " value" to value,
568+ " max" to max,
569+ )
570+ val apiHeaders = mutableMapOf<String , String >(
571+ " content-type" to " application/json" ,
572+ )
573+ val converter: (Any ) -> io.appwrite.models.Document <T > = {
574+ @Suppress(" UNCHECKED_CAST" )
575+ io.appwrite.models.Document .from(map = it as Map <String , Any >, nestedType)
576+ }
577+ return client.call(
578+ " PATCH" ,
579+ apiPath,
580+ apiHeaders,
581+ apiParams,
582+ responseType = classOf(),
583+ converter,
584+ )
585+ }
586+
587+ /* *
588+ * Increment a specific attribute of a document by a given value.
589+ *
590+ * @param databaseId Database ID.
591+ * @param collectionId Collection ID.
592+ * @param documentId Document ID.
593+ * @param attribute Attribute key.
594+ * @param value Value to increment the attribute by. The value must be a number.
595+ * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
596+ * @return [io.appwrite.models.Document<T>]
597+ */
598+ @Deprecated(
599+ message = " This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead." ,
600+ replaceWith = ReplaceWith (" io.appwrite.services.TablesDb.incrementRowColumn" ),
601+ since = " 1.8.0"
602+ )
603+ @JvmOverloads
604+ @Throws(AppwriteException ::class )
605+ suspend fun incrementDocumentAttribute (
606+ databaseId : String ,
607+ collectionId : String ,
608+ documentId : String ,
609+ attribute : String ,
610+ value : Double? = null,
611+ max : Double? = null,
612+ ): io.appwrite.models.Document <Map <String , Any >> = incrementDocumentAttribute(
613+ databaseId,
614+ collectionId,
615+ documentId,
616+ attribute,
617+ value,
618+ max,
619+ nestedType = classOf(),
620+ )
621+
446622}
0 commit comments