Closed niftylettuce closed 8 years ago
That's a good question. There isn't really a great reason why load
is used instead of find
. I thought loadMany
and loadOne
were more descriptive of what the methods were actually doing, as opposed to find
and findOne
.
Also, at that time I had planned on supporting many more DB backends (and I would still like to, eventually), so I didn't want the API to seem like it was just for Mongo.
Looking back on it, there probably wasn't good enough reason to make the change. If enough people want the loadMany
and loadOne
to change to find
and findOne
, I'd be happy to do it.
Thanks!
If enough people want the loadMany and loadOne to change to find and findOne, I'd be happy to do it.
Then, here is my +1 :+1:
Here's my +1.
find
and findOne
are not only related to Mongo. Most ORM wrappers such as ActiveRecord (Rails), EntityFramework (ASP.NET) or GORM (Grails) use find
.
Why not support both? You might think about arguing that "your" API is loadOne
and loadMany
. But by popularity-vote, you would allow aliases, like findOne
and find
for easy usage. That's just some idea~
BTW, I also +1 :)
Thanks for everyone's input!
@minecrawler while I'd like to support loadOne
and loadMany
as aliases, I think this will just add confusion for new Camo users. Would like to keep the API as simple as possible.
Based on feedback I'll be changing loadOne
and loadMany
to findOne
and find
, respectively. Both loadOne
and loadMany
will be deprecated, although they'll be kept as aliases until at least the 1.0 release.
Thanks again!
This also applies to loadOneAndUpdate
and loadOneAndDelete
as well. Here is the full list of changes to be made:
loadOne
--> findOne
loadMany
--> find
loadOneAndUpdate
--> findOneAndUpdate
loadOneAndDelete
--> findOneAndDelete
I'll be updating the .d.ts file in DefinitelyTyped to match this change, then :)
@lucasmciruzzi thanks! The changes should be up later today.
How you would assume 'find' will behave?