J
J
jenya77712018-07-01 20:37:25
Node.js
jenya7771, 2018-07-01 20:37:25

How to use 8 character UUID as id in sequelizejs?

Hello, how to use 8 character UUID as id in sequelizejs?
I can generate it myself, but if it suddenly matches an id that will already be in the database, then there will be an error and the action will not be performed.

id: {
  type: Sequelize.UUID,
  primaryKey: true,
      	autoIncrement: true
  }

I tried to build a table model like this, but an error occurs.
What is the right thing to do so that there is no chance of repeating id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Shashenkov, 2018-07-01
@jenya7771

autoIncrement - you will always have an int.
To avoid repetition, you should generate with a low probability of repetition, for example https://www.npmjs.com/package/uuid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question