
Research
PyPI Package Impersonates SymPy to Deliver Cryptomining Malware
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.
@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);
FAQs
Makes it easy to implement binary(16) uuid's into Sequelize projects.
The npm package @vendit-dev/sequelize-binary-uuid receives a total of 1 weekly downloads. As such, @vendit-dev/sequelize-binary-uuid popularity was classified as not popular.
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.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.