Understandable C# driver

34 views
Skip to first unread message

asdoih...@gmail.com

unread,
Jul 13, 2016, 5:31:50 AM7/13/16
to mongodb-user
Hi!

Some changes that I think would make a more popular C# driver:

For example a lot of methods doing similar things such as InsertOne, InsertMany, UpdateOne, UpdateMany...
How about just use Insert and Update, and work with params so that one could pass a 1:M.

FindOneAndUpdate?
Why not just use update method from above and
mongo.Update(o=>o.id == xx, object);
or even better mongo.update(obj) with underlying id.

Replace vs Update?
Well I am still trying to understand how to update a single field so it would preferble be something like:
mongo.UpdateField(o=>o.id == xx, o=>o.Field = 123);

Finally all AsQueryable operations should do all processing on db server.

I think that if you get a very clean and neat driver, it would increase usage.

Robert Stam

unread,
Jul 13, 2016, 10:02:37 AM7/13/16
to mongod...@googlegroups.com
Thank you for your comments. I can provide some insights into why the methods you refer to are the way they are.

For example a lot of methods doing similar things such as InsertOne, InsertMany, UpdateOne, UpdateMany...
It is a matter of debate whether a single method name with multiple overloads is more understandable. We chose the route of naming the methods more descriptively, which results in more method names and fewer overloads. One of the reasons we did this is that we want consistent method names across our many drivers, and not all languages support overloaded methods.

FindOneAndUpdate?
Actually, Update and FindOneAndUpdate are completely different operations. The server documentation includes a nice summary of the difference between the two methods (see the section "Comparisons with the udpate method" in https://docs.mongodb.com/manual/reference/command/findAndModify/).

Replace vs Update?
There is an UpdateOne method that takes a filter to specify which document to update, and an update specification that defines what modifications should be made to the matching document. Updating a single field is just one of the many possible modifications that can be made to a document. The ReplaceOne method differs from UpdateOne by completely replacing the matching document with a new document (as opposed to making modifications to the existing document).

IQueryable?
All IQueryable operations *are* performed on the server. If you have found a specific case where that is not true please let us know.

Thanks for your feedback. I hope this reply helps you.

Robert



--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/90873423-4f34-4d4a-928d-ff1fb3655fe4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

asdoih...@gmail.com

unread,
Jul 18, 2016, 4:41:47 AM7/18/16
to mongodb-user
Thank you for answer.

Ok I understand that you want a uniform driver, but I still think it would be better to adapt the driver per plattform.
So that developers feel familar and wich I belive would increase popularity :)
Ok thank you I understand it would be like Update / UpdateAny.
I think you could do update for a particular field easier (or in general like an easy crud driver).
Reply all
Reply to author
Forward
0 new messages