2

I've got a simple schema:

export default {
  title: 'hash schema',
  version: 0,
  primaryKey: 'hash',
  type: 'object',
  keyCompression: true,
  properties: {
    uuid: { type: 'string' },
    id: { type: 'number' }
  }
}

I want to have a table with a string field uuid as a primary key and I want to map it to an unique number that is automatically increased.

Is there a way to do so?

Kasper Seweryn
  • 356
  • 1
  • 7
  • 14
  • to be honest, you might need to generate `uuid` yourself. With auto increment for numbers, you will need to look at `orm` functions. check out the documentation. – Tony Ngomana Apr 06 '22 at 18:54

1 Answers1

-2

"automatically incrementing" doesn't sound very UUIDish to me. UUIDs are supposed to be random and unpredictable. You leave yourself vulnerable to the German Tank Problem

Nevertheless, you can indicate a string should be a UUID in JSON Schema by using "format": "uuid". It is only available in implementations supporting specification version draft2019-09 or later.

Ether
  • 53,118
  • 13
  • 86
  • 159