Autoincrement property

Is there any concept of an autoincrement property? In my case, I have an Orders collection and want to use an autoincremenet property. I don’t want to replace the default object id, but rather use another property for a public order number.

Have you looked at newId? Not sequential though, but this is usually more secure than a sequential increasing number.

Otherwise, my guess is that you would need to create a Lambda function to Add an incremental value and Select the value from a meta Document, which contains the current order number (and other settings for your store/app as well).

Since a query is ACID transactional in Fauna, each new order should always get the sequentially next number.

You could also create a Unique Index on the order number to ensure that two orders will never have the same number.

@paplco Excellent points.
I want to mention that this solution can cause contention and performance issues under the Create orders heavy workload. We have a new feature, conflict-free counters, coming soon to address this.

1 Like

I assume you can’t answer but I’ll try. :wink: Any rough ETA? Weeks - months - etc?

It is in the roadmap for next quarter.

2 Likes

I am also interested in this :blush:
In my case: Instead of counting over large (time based)ranges of data sets it would be possible to just do some diff of two counters.