You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suggestion was made from a relatively new user of dstore to add collection.find() to return exactly one/first item. Currently need to use filter()[0] .
Adding it here to consider.
The text was updated successfully, but these errors were encountered:
Worth considering, but challenges I can see with an API like that is that it sort of leads to really bad usage. It sort of indicates that it is a grab bag of results, magically return the "first" object... Who's first object? Also that sort of API also has no way of saying to the user "I found lots of stuff, are you sure you only want the first one". I have seen similar sorts of things lead to all sorts of logic errors or unexpected results.
I am struggling to think of a valid use case where it wouldn't lead to someone shooting themselves in the foot.
If anything, I would prefer to see something like .first() where the API requires some explicit resolution logic of what "first" means so it isn't arbitrary. Of course that lends itself to some sort of Iterator API, which is something I have been thinking about for "dstore 2" which would be able to provide native/polyfilled iterators as well as delta change API.
Suggestion was made from a relatively new user of dstore to add collection.find() to return exactly one/first item. Currently need to use filter()[0] .
Adding it here to consider.
The text was updated successfully, but these errors were encountered: