[CXX-925] How to upsert a replace_one in C++11 driver? Created: 08/Jun/16 Updated: 11/Sep/19 Resolved: 13/Jun/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Implementation |
| Affects Version/s: | 3.0.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Trivial - P5 |
| Reporter: | George Thompson | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 |
||
| Issue Links: |
|
||||
| Description |
|
According to the update tutorial to replace one: db[this->id()].replace_one(filter_builder.view(), bsb_file_blueprint.view()); It goes on to state:
referring me to the C++11 documentation but without an example. I have (using the bulk_write.cpp example): {{mongocxx::model::replace_one upsert_op(filter_builder.view(), bsb_file_blueprint.view()); But I'm unsure what to do next. Am I to do a bulk_write? Is there an easier way? |
| Comments |
| Comment by George Thompson [ 09/Jun/16 ] |
|
Thank you Andrew. I was focusing on the mongocxx::model::replace_one linked from the tutorial when, naturally, I should have been focusing on mongocxx::collection class. I have an entire tab group dedicated to the c+11 classes and I should have caught that easily. Possibly the tutorial should point to the collection class vs. model? Thanks as always. |
| Comment by Andrew Morrow (Inactive) [ 08/Jun/16 ] |
|
There are two ways to do what you want:
In fact, the latter method is just shorthand for the first. You may find looking at the implementation of mongocxx::collection::replace_one helpful: |