Bulk API - replaceOne

44 views
Skip to first unread message

Travis Terry

unread,
Aug 3, 2016, 10:55:12 AM8/3/16
to mgo-users
Hi. I'm trying to use the bulk API, and I have a few problems. Coming from using pymongo, it seems like mgo's bulk implementation is missing a few things.

1. I can't find replaceOne. 
2. The BulkResult struct is missing values like nInserted, nRemoved, upserted, etc that are present in the raw mongo response.
3. Looking at the code in bulk.go, it appears that Bulk.Run() merely loops over the individual requests and sends them to the server individually the same as I would without bulk. Does mgo actually use the bulkWrite functionality in mongo 2.6+?


Gustavo Niemeyer

unread,
Aug 3, 2016, 1:27:03 PM8/3/16
to mgo-...@googlegroups.com
On Wed, Aug 3, 2016 at 4:55 PM, Travis Terry <tdte...@gmail.com> wrote:
Hi. I'm trying to use the bulk API, and I have a few problems. Coming from using pymongo, it seems like mgo's bulk implementation is missing a few things.

1. I can't find replaceOne. 

 
The names in mgo are Update and UpdateAll. The other MongoDB drivers finally decided to split the functionality into two different functions instead of piggy backing onto a single confusing API, but unfortunately they've mimicked the idea in mgo but not the names. It's been like that in mgo for years.

2. The BulkResult struct is missing values like nInserted, nRemoved, upserted, etc that are present in the raw mongo response.

BulkResult is work in progress indeed,  Here is what you can find there today:


We can easily improve it to have more as necessary, but we want an API that works across releases so needs a bit of care.
 
3. Looking at the code in bulk.go, it appears that Bulk.Run() merely loops over the individual requests and sends them to the server individually the same as I would without bulk. Does mgo actually use the bulkWrite functionality in mongo 2.6+?

Yes, bulk does use bulk support.  There is fallback logic for the older releases, though.


Reply all
Reply to author
Forward
0 new messages