Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

type error for composite primary keys in service options #94

@robbyphillips

Description

@robbyphillips
  const options = {
    Model,
    id: ['entityId', 'otherEntityId'],
    paginate: app.get('paginate')
  }

Throws a type error, "string[] is not assignable to string", but according to the feathers-objection docs, this is how you use composite primary keys.

Unfortunately, I think fixing this also requires a change in feathers. It looks like the upstream feathers AdapterService class doesn't allow a way to override its options object type. So, even if we did

export interface ObjectionServiceOptions extends Omit<ServiceOptions, 'id'> {
  model: typeof Model;
  id: string | string[];  // <--change
  // ...
}

We would still get a type error here:

export class Service<T = any> extends AdapterService<T> implements InternalServiceMethods<T> {
  Model: typeof Model;
  options: ObjectionServiceOptions;
  // ...
}

The actual fix is probably to make the feathers AdapterService accept an additional type parameter: AdapterService<T = any, S = ServiceOptions>, or to change ServiceOptions, but I think that might be more breaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions