Bookshelf custom ID?

I am using custom IDs in my models that get generated on the model’s create methods. I am using the npm uid-generator package to do this. I stumbled across the bookshelf-uuid plugin and wondered if this was created to do the same thing that i am trying to do.

What i would like is to have the admin panel use the custom uuid instead of the auto-incremented id database column. Is this possible? I installed the bookshelf-uuid plugin and added the bookshelf.js file as described in the documentation, but i cant seem to figure out what this plugin is doing?


We removed the option to customize the primaryKey (on all databases) for the moment due to some large architectural changes that are needed to handle it properly (we still have hard coded references to the name id and the data type integer / objectID)

For now you can use the uuid plugin for another field but not the primary key.

We will eventually add this back in as it was removed around the stable release, but we need to fix the other issues first to make it viable.

1 Like

So i have a secondary field that i insert the uuid into upon creating the record, so are you saying there is currently no way to have the admin/api interfaces use something other than the primary key by default when updating/finding records?

If so what purpose does the bookshelf-uuid plugin provide at this time? The documentation on this plugin is sparse.

It just adds in support for generating UUIDs on databases that don’t normally have a built in UUID generator (MySQL/MariaDB). And it’s left over as an example in our documentation to provide context on adding other bookshelf plugins.

Both admin/api you can filter/search for this UUID field but it’s not the default no.


Also see:

Similar to swapping out the slug for a UUID and creating a custom route/controller


I have a UUID field linked the “xxxxx_id” (like a title field - string/text field) and I have create the models beforeCreate to generate an new UUID when my new content is create by user via an endpoint API but I have an error 500 who said “duplicate id” when I have two contents to have the similar xxxxx_id.

We can’t geneate UUID by endpoint API content ? Thx

lifecycles: {
beforeCreate: async (data) => {
if (data.xxxxx_id) {
data.slug = slugify(data.xxxxx_id);

  • Mongoose database
  • Last v. Strapi (3.5.4)