feathersjs-ecosystem / dataloader

MIT License
6 stars 2 forks source link

Help with load() method querying non-standard ID field in Feathers.js #9

Open nesgarbo opened 6 days ago

nesgarbo commented 6 days ago

Hi everyone,

I’m currently maintaining an application that connects to an AS/400 database, which is expected to be replaced with PostgreSQL in the future. I didn’t create the original database structure, which leads to some challenges, particularly regarding how IDs are handled.

I've managed to work around the lack of a standard id field by using a resolver that points to a different property (like codcli instead of id). However, I'm now facing issues when using the load() method in Feathers.js, as it automatically searches for the id field in queries, whereas in my case, the id is a resolver pointing to another field.

Is there a way to customize the behavior of the load() method to search for my custom codcli field instead of id? I want to make use of the batching and caching benefits of DataLoader, but I’m stuck due to this ID issue.

Any help would be appreciated!

DaddyWarbucks commented 6 days ago

I believe you are looking for the .key() method.

loader.service('users').key('username').load('FeathersUser', params)