idb-ts
    Preparing search index...

    Function CompositeKeyPath

    • Class decorator that defines a composite primary key spanning multiple fields. Use this when the entity's identity is determined by a combination of fields rather than a single property.

      Parameters

      • fields: string[]

        An ordered array of field names that together form the key.

      • Optionaloptions: KeyPathOptions

        Optional key generation configuration (note: auto-generated keys are not supported for composite keys).

      Returns ClassDecorator

      Apply @CompositeKeyPath before @DataClass (decorators execute bottom-up). @KeyPath must not also be used on the same class.

      @CompositeKeyPath(['userId', 'projectId'])
      @DataClass()
      class UserProject {
      userId!: string;
      projectId!: string;
      role!: string;
      }

      // Read by composite key:
      const rel = await db.UserProject.read(['user1', 'proj42']);