Closed mdartic closed 1 year ago
I'm trying to port feathers-objection and discover in the AdapterServiceOptions that id can only be a string
feathers-objection
AdapterServiceOptions
id
https://github.com/feathersjs/feathers/blob/dove/packages/adapter-commons/src/declarations.ts#L30
How do we manage composite keys ?
For example, in an association table, where the primary key is composed of the two foreign tables.
Actually, I transform the id property of service options in a string | string[] and rewrite some parts of the _find methods like this
string | string[]
_find
const idColumns = Array.isArray(this.id) ? this.id : [this.id] const fullIdColumns = idColumns.map((idc: string) => `${this.table}.${idc}`) // provide default sorting if its not set if (!filters.$sort) { builder.orderBy( fullIdColumns.map((fic: string) => ({ column: fic, order: 'asc', })) as ColumnRefOrOrderByDescriptor[], ) }
And also for the count request.
count
Do you think this is the "right" way to do it, or maybe there is another way ?
I'm trying to port
feathers-objection
and discover in theAdapterServiceOptions
thatid
can only be a stringhttps://github.com/feathersjs/feathers/blob/dove/packages/adapter-commons/src/declarations.ts#L30
How do we manage composite keys ?
For example, in an association table, where the primary key is composed of the two foreign tables.
Actually, I transform the
id
property of service options in astring | string[]
and rewrite some parts of the_find
methods like thisAnd also for the
count
request.Do you think this is the "right" way to do it, or maybe there is another way ?