New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bookshelf-uuid-column

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-uuid-column

Automatically generates UUID for your models in a custom column

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bookshelf-uuid-column

Build Status Code Climate Test Coverage Version Downloads

Automatically generate UUIDs for your models and let you choose the column name.

Useful if you are using standard integer primary keys but prefer not to expose these to the public, rather identifying your resources based on an unique ID.

Installation

After installing bookshelf-uuid-column with npm i --save bookshelf-uuid-column, 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
bookshelf.plugin(require('bookshelf-uuid-column'))

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

Usage

Nothing fancy here, just keep using bookshelf as usual.

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

Settings

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

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

Testing

git clone git@github.com:jesobreira/bookshelf-uuid-column.git
cd bookshelf-uuid-column && npm install && npm test

Keywords

FAQs

Package last updated on 07 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc