Skip to content
Back

How to increment integers in Appwrite

  • 0
  • Databases
  • REST API
Prince Gupta
18 Dec, 2024, 18:26

Hi everyone, sorry for asking a simple question here. I'm building a blog website with Appwrite, and I want to increment the like count stored in the database.

In MongoDB, I can use $inc, and in SQL-based databases, I can use an UPDATE query to achieve this.

My question is: how can I do this in Appwrite? The only workaround I can think of right now is to retrieve the count from the database, increment it in my code, and then update the database. However, I feel this might not be ideal for performance.

TL;DR
To increment integers in Appwrite, you can use the $inc operation. This is similar to how you would do it in MongoDB. It's recommended to avoid retrieving the count from the database and instead perform the increment operation directly.
joe_2512 <-- UBI
18 Dec, 2024, 18:35

Yes only way… at least that i know off… did you try to use $inc?

Beacuse there is the same thing for array and I managed to use $push

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more