Skip to content

Binary UUID : PR Wanted?  #10265

Closed
Closed

Description

@bradennapier

#9272

I wrote out a skeleton for how we can support UUID Binary type as recommended by MySQL team and many other articles to store uuid as binary(16).

I’m happy to look into implementing it as a PR for official support as a data type if it would be welcomed by the team as an addition.

My time is somewhat limited in coming months so don’t want to do unless it’s a desired feature :)

Specifically take a look at the last post where I implement the uuid stuff client side.

Activity

  1. sushantdhiman commented on Dec 14, 2018

    @sushantdhiman
    Contributor

    Yes

  2. bradennapier commented on Dec 21, 2018

    @bradennapier
    Author

    @sushantdhiman So I put that PR together but realized there are probably quite a few places that I would be missing potentially important pieces. I extracted the core values into two packages and published them to npm and tested.


    Specifically around how to handle the new BINARY type (I played with using UUIDV1.BINARY as the default value for this which seems to work then having a BINARY type as the module below defines.

    I wasn't sure how to best handle the virtual field in this case in a way that works similar to precedent. It's fairly important IMO to be able to still get the human-readable values. Seems some kind of transform hook would be good to always provide to the user as a string but always save to db as the binary. This may already be available that I may be missing.


    https://github.com/odo-network/binary-uuid

    https://github.com/odo-network/sequelize-binary-uuid

    import Sequelize from "sequelize";
    import { withBinaryUUID } from "sequelize-binary-uuid";
    
    const User = sequelize.define(
      "User",
      withBinaryUUID(
        {
          // any other fields here
          someKey: Sequelize.DataTypes.TEXT
        },
        {
          primaryID: "id", // default
          virtualID: "uuid", // default
          field: {
            primaryKey: true
          }
        }
      )
    );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions