idb-ts
    Preparing search index...

    Function KeyPath

    • Property decorator that designates the decorated field as the primary key (key path) for the entity's IndexedDB object store.

      Exactly one property per entity class may be annotated with @KeyPath. For composite keys spanning multiple fields, use CompositeKeyPath at the class level instead.

      Parameters

      • Optionaloptions: KeyPathOptions

        Optional key generation and auto-increment configuration.

      Returns PropertyDecorator

      The decorator stores KeyPathMetadata via reflect-metadata on the constructor. The @DataClass decorator validates at class decoration time that exactly one key path is present.

      @DataClass()
      class Document {
      @KeyPath({ generator: 'uuid' })
      id!: string;
      }
      @DataClass()
      class Task {
      @KeyPath({ autoIncrement: true })
      id!: number;
      }