I have not used UUID’s so I may be wrong in my theory.
The first thing that I noticed is that you are using UUID for the ID of the field. Normally the field ID would be an integer of 4 bytes which makes indexing a simple matter. UUID’s are 36 bytes which requires extra memory to index.
Secondly, you need to create the value of the UUID before it can be inserted into the database as shown in
Knex is a 3rd party library that we use for database connections within NodeJS. However knex currently doesn’t support returning for MariaDB database. Knex uses LAST_INSERT_ID() to get the identity in MySQL and MariaDB, it returns the first column which has AUTO_INCREMENT on it. The latest MariaDB supports returning, its only the library that didn’t implement this.
Do I understand correctly that due to the fact that Knex does not support returning the uuid in MySQL/MariaDB, it is impossible to get the uuid of the inserted record in Wappler today?
I’ve checked with Knex again to see if there is some progression, seems they didn’t go any further with it. There was a PR last year for it but it was not accepted. I will investigate if we can work around it.
I know that this topic is from a previous era, but why not leverage both: UUIDs for public-facing identifiers and integers for internal logic and sequencing? It’s a pragmatic combo — one that balances global uniqueness with performance and clarity.
It’s also worth highlighting that UUIDv7 is the rising star of the format family. Time-orderable, globally unique, and much easier to grok during debugging, it brings together the best of both worlds.
To generate UUIDv7 in Wappler, you’ve got two solid routes:
Custom Module
Install the package:
npm install uuidv7
Create a file in your modules folder — say, uuidv7.js:
Edit: To clarify — you’re not actually using a "dual PK" setup. You’ve got a single primary key (likely the integer), with the UUID as a secondary column for external reference, tracking, or exposure in API endpoints. Clean separation, clearer intent.
@patrick, UUIDv7 may be worth introducing into Wappler.