Return results of findMany as map by id field value as key #5305
MurzNN
started this conversation in
Feature requests
Replies: 3 comments 1 reply
-
You can always create reducer to map it as such. It needs be done either on server or on client. Database does not return result in the form other than array |
Beta Was this translation helpful? Give feedback.
1 reply
-
I add same feature request directly to Prisma client prisma/prisma#6258 because this feature better to implement on adapter level, than on Keystone's side. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for the update @MurzNN. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
At now the
findMany()
function returns the plain array of item objects, and there is not convenient to access individual items in it.For example, I have users with ids = 123, 456, 789 and 100+ more items in result of
findMany
, and need to find the user with id = 456. I see only the way to iterate of all items viaArray.find()
function, that will eat too much resources for each search.For solve this problem will be good to add option for return the
map
of item objects, with id (or, optionally, other required unique field value) as key. Other way is return the object by item id, but searching item in object is not very quick operation too, so map will be better.What do you think about this idea?
Beta Was this translation helpful? Give feedback.
All reactions