idb-ts
    Preparing search index...

    Function DataClass

    • Class decorator that marks an entity class for use with Database.

      @DataClass must be applied after @KeyPath (or @CompositeKeyPath) and performs the following at decoration time:

      1. Verifies that exactly one @KeyPath (or @CompositeKeyPath) annotation is present on the class.
      2. Records the schema version in reflect-metadata.
      3. Marks the class as a valid data class (guards against passing plain classes to Database.build).

      Parameters

      Returns ClassDecorator

      Error - If no @KeyPath / @CompositeKeyPath annotation is found.

      Error - If more than one property-level @KeyPath annotation is present (use @CompositeKeyPath for multi-field keys instead).

      @DataClass({ version: 2 })
      class User {
      @KeyPath({ generator: 'uuid' })
      id!: string;

      @Index({ unique: true })
      email!: string;

      name!: string;
      }