Open szabgab opened 7 years ago
Hi Gabor,
Sorry for the long time you had to wait, I am on a holiday in a very absent wifi area.
Thank you for looking into this module. The insert() and friends have been there in the beginning of 2015 but I've removed them. Mongodb has a way to do many things with its runCommand after version 2.6 (even find) so after a long thought I cut it out. Also because you can think up all sorts of helper functions, the modules will become too large. There is a blog from Mongodb about an advise not to provide these helper functions and I was merely following that too.
Another thing which played into this decision is the following; mongodb uses the so called wire protocol to communicate with the server. There are structures defined for query, insert, update, delete, etc. The insert() for example was based on that protocol. The problem with insert, update and delete however, is that there is no response from the server after sending the data. Therefore you needed another call to find out if the action was performed correctly. With 2.6, these actions can now be done with the runCommand (run-command method) which also returns info about its success or failure. So with the removal of these functions I could also cut a big part of the wire protocol. The downside of this is that the modules can not support 2.4.* and lower. We should perhaps discuss the support of this later.
What I can do, is providing a 'higher level' module where these functions are provided based upon run-command() to keep the main modules as small as possible.
Regards, Marcel
On July 7, 2017 3:14:07 PM Gabor Szabo notifications@github.com wrote:
use BSON::Document; use MongoDB::Client; my $client = MongoDB::Client.new(:uri('mongodb://')); my $database = $client.database('myProject'); my MongoDB::Collection $collection = $database.collection('people'); $collection.insert: ( name => "Foo Bar", );
gives me
No such method 'insert' for invocant of type 'MongoDB::Collection'. Did you mean 'invert'?
I know there are other ways to insert a document, but I wonder if this should be also included as this seems to be the method used in the MongoDB API.
-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/MARTIMM/mongo-perl6-driver/issues/21
The higher level module sounds like an excellent compromise. In general I, as a user of the module, would like to write as little as possible.
gives me
I know there are other ways to insert a document, but I wonder if this should be also included as this seems to be the method used in the MongoDB API.