Details
-
Task
-
Resolution: Done
-
Major - P3
-
None
-
legacy-1.0.0
Description
Looks there are 2 ways to do the bulk insert:
1. the older way, i.e. insert a vector via mongo::DBClientConnection insert() API.
2. the newer way, i.e. use mongo::BulkOperationBuilder insert() and execute() API.
To check errors for #1, we call getLastError(const std::string &db, bool fsync=false, bool journal =false, int writeconcern=0, int wtimeout=0)
To check errors for #2, call mongo::BulkOperationBuilder execute (const WriteConcern *writeConcern, WriteResult *writeResult), second parameter will provide the error code.
For #2, the API allow us to specify writeconcern, but not fsync or journal.
I have following questions:
1. is #2 the recommended way to do bulk operations?
2. If so, is there a way to specify fsync and journal when we use the #2 .
3. If we do not use bulk API, i.e. we insert 1 document at a time what is the recommended way to check errors?
4. Is that true that getLastError() is going to be deprecated?
Thanks!
Judy