Automatically generates UUIDs for your bookshelf models
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test First version May 12, 2016
.gitignore First version May 12, 2016
LICENSE First version May 12, 2016 First version May 12, 2016
circle.yml First version May 12, 2016
index.js First version May 12, 2016
package.json 1.0.0 May 12, 2016


Build Status Code Climate Test Coverage Version Downloads

Automatically generate UUIDs for your models


After installing bookshelf-uuid with npm i --save bookshelf-uuid, all you need to do is add it as a bookshelf plugin and enable it on your models.

let knex = require('knex')(require('./knexfile.js').development)
let bookshelf = require('bookshelf')(knex)

// Add the plugin

// Enable it on your models
let User = bookshelf.Model.extend({ tableName: 'users', uuid: true })


Nothing fancy here, just keep using bookshelf as usual.

// This user is indestructible
let user = yield User.forge({ email: 'foo@bar' }).save()
console.log( // 6b7a192f-6e1c-4dcb-8e57-14ab16d5fdf4


bookshelf-uuid generates UUIDs v4 by default, but you can easily switch to v1 UUIDs or a custom generator.

bookshelf.plugin(require('bookshelf-uuid'), {
  type: 'v1' // Or your own function


git clone
cd bookshelf-uuid && npm install && npm test