I need to insert a new record into a PostgreSQL table and specify the value for the ID field using UUIDv4. I am wondering if there is an existing function to generate UUID, or if I need to implement one myself using Math.random. I also noticed that the browser has a built-in crypto function for UUID generation, but it is not yet supported in Appsmith.
The task is to insert a new record into a PostgreSQL database table and specify an ID value using UUIDv4. One way to generate UUID is to use Math.random, but it is not advisable.
INSERT INTO mytable (id, column1, column2)VALUES (uuid_generate_v4(), 'value1', 'value2');
let myUUID = crypto.randomUUID();
This uses the Crypto interface available in the current context to access a cryptographically strong random number generator and cryptographic primitives.