
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
@vendit-dev/sequelize-binary-uuid
Advanced tools
Makes it easy to implement binary(16) uuid's into Sequelize projects.
This builds upon the binary-uuid package by making it easy to implement into Sequelize.
This package provides a few important exports:
BINARY type (binary(length)).BINARYUUID field creator.VIRTUALBINARYUUID field creator.withBinaryUUID preset field creator.This package makes it easy to use binary(16) UUID's instead of CHAR(36) which is the default. It also modifies the UUID so that it is more performant when indexing which can lead to significant performance improvements over naive implementations.
Multiple examples are available in the examples folders.
withBinaryUUID preset (recommended)When utilizing the preset, the model will be created with an id field which is the primaryKey and is a generated binary(16) uuid value.
In addition, the model will have a uuid virtual field which is the string version of the uuid.
import Sequelize from 'sequelize';
import { withBinaryUUID } from 'sequelize-binary-uuid';
// define sequelize...
const User = sequelize.define(
'User',
withBinaryUUID(
{
// any other fields here
someKey: Sequelize.DataTypes.TEXT
},
{
primaryID: 'id', // default
virtualID: 'uuid', // default
field: {
// optionally provide extra parameters to the
// `primaryID` binary field
primaryKey: true
// primaryKey: true is required to make it a
// primaryKey!
}
}
)
);
Once you have done this, you may interact with the table:
sequelize
.sync({ force: true })
.then(() =>
Promise.all([
User.create({ someKey: 'one' }),
User.create({ someKey: 'two' }),
User.create({ someKey: 'three' })
])
)
.then(() => User.findAll())
.then(users => users.map(user => user.get({ plain: true })))
.then(console.log);
[
{
uuid: '8cde7820-04c1-11e9-8d40-0d6e8c185c6c',
id: <Buffer 11 e9 04 c1 8c de 78 20 8d 40 0d 6e 8c 18 5c 6c>,
someKey: 'one',
createdAt: 2018-12-21T01:41:35.000Z,
updatedAt: 2018-12-21T01:41:35.000Z
},
{
uuid: '8cdec640-04c1-11e9-8d40-0d6e8c185c6c',
id: <Buffer 11 e9 04 c1 8c de c6 40 8d 40 0d 6e 8c 18 5c 6c>,
someKey: 'two',
createdAt: 2018-12-21T01:41:35.000Z,
updatedAt: 2018-12-21T01:41:35.000Z
},
{
uuid: '8cdec641-04c1-11e9-8d40-0d6e8c185c6c',
id: <Buffer 11 e9 04 c1 8c de c6 41 8d 40 0d 6e 8c 18 5c 6c>,
someKey: 'three',
createdAt: 2018-12-21T01:41:35.000Z,
updatedAt: 2018-12-21T01:41:35.000Z
}
]
IMPORTANT: It is important to note here that the
uuidfield isVIRTUAL- this means it is NOT stored in the database and is only provided as a convenience.
Using the BINARYUUID helper we can define a field as being a binary UUID. This will use a binary(16) type and will generate a uuid by default if none is provided.
import Sequelize from 'sequelize';
import { BINARYUUID } from 'sequelize-binary-uuid';
// define sequelize...
const User = sequelize.define('User', {
// ... your model definition ...
binaryUUID: BINARYUUID({
// field params here...
allowNull: true
})
});
NOTE: If you set
allowNulltotruethen a binary uuid will not be generated when the field is not provided. You will need to provide one yourself.
Using VIRTUALBINARYUUID will make it easy to provide a VIRTUAL field which resolves to the initial string version of the uuid for the given field.
VIRTUALBINARYUUID expects two arguments. First, the target field (the binary uuid) then the source field (the string/virtual field).
import Sequelize from 'sequelize';
import { BINARYUUID, VIRTUALBINARYUUID } from 'sequelize-binary-uuid';
// define sequelize...
const User = sequelize.define('User', {
// ... your model definition ...
binaryUUID: BINARYUUID({
allowNull: false
}),
stringUUID: VIRTUALBINARYUUID('binaryUUID', 'stringUUID')
});
BINARY typeIf you wish to construct your own binary type and/or binary UUID values, you can follow the example below.
import Sequelize from 'sequelize';
import { BINARY, getBinaryUUID } from 'sequelize-binary-uuid';
// define sequelize...
const User = sequelize.define('User', {
// ... your model definition ...
customBinaryUUID: {
type: BINARY(16)
}
});
// .. later
User.create({
customBinaryUUID: getBinaryUUID()
});
As a convenience, this package also re-exports some helpers from binary-uuid, as well as some helper functions.
import { getBinaryUUID, fromBinaryUUID, toBinaryUUID } from 'sequelize-binary-uuid';
const buf = getBinaryUUID();
const uuid = fromBinaryUUID();
const buf2 = toBinaryUUID(uuid);
This is Forked from Sequeilze-binary-uuid for maintain sequelize package version.
FAQs
Makes it easy to implement binary(16) uuid's into Sequelize projects.
We found that @vendit-dev/sequelize-binary-uuid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

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.

Security News
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.