Is there a way to auto increment a number field in RxDB?

Viewed 271

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?

1 Answers

"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.

Related