How to create auto-increment ID's in CloudKit JS?

489 views Asked by At

Is there a solution for this in CloudKit JS? I have not been able to write a successful query to even get the ID of a Record.

The question in this link was here before, it is related if you'd like to take a look.

How to query for Metadata in CloudKit JS?

1

There are 1 answers

0
Dave Browning On BEST ANSWER

In CloudKit, the recordName is a Record's unique identifier. You can specify one yourself when creating a record or not specify it and let the server create a UUID for you. When fetching one or more records, you can access it via the recordName property.

You could have an auto-incrementing id if you specified the recordName yourself, but that would be quite cumbersome to manage for a system with distributed clients. It's likely that you'll instead want to allow the server to create the recordName UUID for you. You could then query the records and sort by creation date if you wanted to know the order in which they were created.