scottwrobinson / camo

A class-based ES6 ODM for Mongo-like databases.
556 stars 80 forks source link

Why not use `findOne` and `find`? #37

Closed niftylettuce closed 8 years ago

michaeljota commented 8 years ago

How you would assume 'find' will behave?

scottwrobinson commented 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!

loucyx commented 8 years ago

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:

wollnyst commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

This also applies to loadOneAndUpdate and loadOneAndDelete as well. Here is the full list of changes to be made:

loucyx commented 8 years ago

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

scottwrobinson commented 8 years ago

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