marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

Added getLastError() #7

Closed aarongreenlee closed 13 years ago

aarongreenlee commented 13 years ago

I added the unit test for getLastError() and gave Mongo.cfc the ability to return getLastError().

This pull request also includes changes to the way defaults for complex objects are handled within Mongo.cfc to stop CFBuilder from crying. Thanks!

marcesher commented 13 years ago

Hey Aaron, Thanks for the contributions! Here are my thoughts: 1) I like the addition of getLastError. Thank you. 2) I'm not at all a fan of ripping out the defaults from the function signature just because CFBuilder can't handle it. I can also confirm that CFBuilder 2 properly colors the arguments. In general, I'm not a fan of changing code just because an IDE doesn't completely work with it. And things work fine in CFEclipse, too, so... knowing that CFB 2 solves the problem, and knowing that CFE already properly handles it, I'm kind of not inclined to stop using rich defaults and instead duplicate the idea of a default in code.

Does that make sense?

I dunno... I'm torn. I see your point, it's a valid one, I just hate having to do it is all ;-). Stupid CFB.

I'm gonna pull all these changes and mull it over.

Meanwhile, what would you think about us refactoring Mongo.cfc to include a new Collection.cfc which takes over most of the work of Mongo.cfc? we'd still provide functions for backwards compatibility, but they'd just delegate to Collection. Also, I'd like to change "search" to "find"

So in essence you'd do this:

people = mongo.getCollection("people"); people.query().$lte("age",5).$eq("name","Marc").find(); people.insert({"name"="Aaron"}); etc

instead of

mongo.query("people").$lte("age",5).$eq("name","Marc").search();

What do you think?

Thanks!

Marc

aarongreenlee commented 13 years ago

I agree with your comments about CFB and expected push back. I hesitated to make the commit, but, after thinking about it I thought it would be important for adoption to support the tools in use. My first impression was "Oh no! Something is wrong with this new library I downloaded!" I'll be previewing CFB2 shortly so it wont bother me much longer--but, it will bother someone. I just want to add value and I'll happily deffer to your judgement.

I agree with the idea of adding a Collection.cfc. I actually expected it to be organized like that when I dove in :).

Keep it up and thanks!

marcesher commented 13 years ago

pulled. Thanks Aaron!