feathersjs-ecosystem / feathers-objection

Feathers database adapter for Objection.js, an ORM based on KnexJS SQL query builder for Postgres, Redshift, MSSQL, MySQL, MariaDB, SQLite3, and Oracle. Forked from feathers-knex.
MIT License
98 stars 48 forks source link

Typescript error for GET request when using composite key #138

Open idandagan1 opened 3 years ago

idandagan1 commented 3 years ago

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

robbyphillips commented 3 years ago

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.