Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not use findOne and find? #37

Closed
niftylettuce opened this issue Jan 17, 2016 · 9 comments
Closed

Why not use findOne and find? #37

niftylettuce opened this issue Jan 17, 2016 · 9 comments

Comments

@niftylettuce
Copy link

No description provided.

@michaeljota
Copy link

How you would assume 'find' will behave?

@scottwrobinson
Copy link
Owner

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!

@loucyx
Copy link

loucyx commented Feb 16, 2016

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 👍

@wollnyst
Copy link

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.

@minecrawler
Copy link

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 :)

@scottwrobinson
Copy link
Owner

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!

@scottwrobinson
Copy link
Owner

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

@loucyx
Copy link

loucyx commented Feb 24, 2016

I'll be updating the .d.ts file in DefinitelyTyped to match this change, then :)

@scottwrobinson
Copy link
Owner

@lucasmciruzzi thanks! The changes should be up later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants