Replies: 1 comment
|
Alternatively, I do see mongo already has a $first property for its API which could be confusing so this could be $front, $shift, $zero or something similar. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm finding in my application often times I want to get one result by something other than its ID. As far as I know, the only way to do this is to do a find(), pass in a
$limit: 1and then grab the first result from the result.That's really not a big deal, but I feel like this is a very common thing and having a $first parameter would be a nice quality of life feature; especially if you have some routes with pagination and others without as you then need to remember if its
results[0]orresults.data[0].All this would do is define the $limit:1 for you and force the returned object to be the first index. Essentially this would add a built in way of doing a get() thats not tied to the id, great for columns with unique indexes or if you only care about the last entry made based on a timestamp, etc.
Compared to:
I have added a hook for this to my own app incase this doensn't go anywhere but someone else thinks this would be useful.
All reactions