feathers-objection icon indicating copy to clipboard operation
feathers-objection copied to clipboard

Typescript error for GET request when using composite key

Open idandagan1 opened this issue 4 years ago • 1 comments

Hi, I'm using typescript with feathers-objection. And trying to make a GET request with composite-key like in the readme example:

app.service('/user-todos').get([1, 2])

But I get type error:

Argument of type 'number[]' is not assignable to parameter of type 'string | number'

Because feathers define the id to be type Id = number | string;

As a workaround I'm currently using find method instead of get. Any suggestions?

10x

idandagan1 avatar Dec 29 '20 07:12 idandagan1

A better workaround is probably to .join(',') your ids to get a comma-separated string as shown here: https://github.com/feathersjs-ecosystem/feathers-objection#composite-primary-keys

But yeah, the actual solution is probably to have this lib override the default feathers id type.

robbyphillips avatar Dec 29 '20 17:12 robbyphillips