Skip to content

Using $sequence to track row order in Appwrite_

Learn how to use Appwrite's $sequence column to track row order in your database.

6 min readUpdated Jun 29, 2026

Some systems need to reflect the order in which actions happen. A ticketing system, for example, should assign "Ticket #41" before "Ticket #42". But in a user interface, it often makes sense to display the latest tickets first, so "Ticket #42" may appear above #41.

Relying on timestamps to get this right is often not enough. Two rows can be created almost simultaneously, and the sort order might vary. What is needed is a consistent, backend-assigned number that increases with each insert and cannot be modified or skipped.

Appwrite's $sequence column provides exactly this. Every time a row is added to a table, the system assigns it a unique, auto-incrementing integer. This value reflects the insert history of the table and can be used for sorting, display, filtering, and pagination.

In this tutorial, we will build a simple web-based support ticket tracker using plain HTML and JavaScript. Each submitted ticket will be stored in Appwrite with a title and description, and each will receive a $sequence number automatically. We will use that number to display and order the tickets.

What you have built

You now have a working support ticket tracker that looks like this:

Support tracker demo
Support tracker demo

  • Each submitted ticket is stored as a row in Appwrite
  • Every row receives a $sequence number, guaranteed to be unique and increasing
  • The interface displays each ticket using that number
  • The ticket list is reliably sorted by creation order

There was no need to write any logic to generate numbers, track counters, or manage collisions. Appwrite's $sequence column handled the sequence internally, which was great for our use case.

Conclusion

This tutorial introduced the auto-incrementing $sequence column and demonstrated how to use it in a small, working app. It offers a solution to a common need: preserving the order of inserts in a predictable, integer-based way.

Because the value is assigned by your database, $sequence remains stable even as your application grows. You can filter by it, paginate through it, or display it directly in user interfaces. And since it is read-only and immutable, we avoid the risk of errors that often come with custom counters or timestamp sorting.

This pattern can extend far beyond tickets. You can use $sequence for invoices, order numbers, log entries, approval requests, or anything where sequence matters.

Here's a link to the GitHub repository for this tutorial: Simple Support Tracker.

Looking forward to seeing what you build with this!

Resources

Read next

Introducing Appwrite Explorer

Eldad Fux

Appwrite Explorer brings the Appwrite REST API into the Console. Browse every endpoint, build requests with guided forms, send live calls against your project, and inspect responses without leaving the browser.

8 min read

Introducing Appwrite Terminal

Eldad Fux

Appwrite Terminal runs the Appwrite CLI directly inside the Console. Your session and project context are preconfigured, with keyboard-first controls and multi-tab workflows, so you can inspect resources without leaving the project.

7 min read

Ready to build?_