how do I add a UNIQUE constraint to a table column when creating table using Yandex YDB SDK? I am using JavaScript version of the SDK, however, any slightest insight about how it is done on any version of the SDK would be much appreciated.
Searching for clues using "unique" keyword in https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples has returned no results.
You don't need unique indexes in YDB. YDB operates at a serializable isolation level according to https://ydb.tech/en/docs/concepts/transactions, so you can simply check if a record with column value K exists, and if not, create a new one. If both operations (check and insert) are performed in one transaction, then it will be guaranteed that only one record with the value K will be inserted into the database.