[CDRIVER-3093] Include inserted _Ids in insert_one() and insert() results Created: 23/Apr/19 Updated: 07/Mar/23 |
|
| Status: | Backlog |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Stennie Steneker (Inactive) | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | Improve Developer Experience | ||||||||
| Quarter: | FY24Q3 | ||||||||
| Case: | (copied to CRM) | ||||||||
| Description |
|
As per http://mongoc.org/libmongoc/current/mongoc_collection_insert_one.html and http://mongoc.org/libmongoc/current/mongoc_collection_insert.html, there is currently no option to return the generated _id(s):
Although providing the inserted id(s) is not required according to the MongoDB CRUD spec, it would be useful to expose this in the C driver to assist downstream drivers such as mongolite that use libmongoc. |
| Comments |
| Comment by Kevin Albertson [ 10/Jun/19 ] |
|
Hi stennie, is there another issue to link to? |
| Comment by Jeremy Mikola [ 14/May/19 ] |
|
stennie: Still waiting for an issue to cross-reference if you have it handy. On a separate note, this issue came up in relation to PHPLIB-428. While implementing the retryable writes test runner, I realized that it's quite difficult to assert inserted IDs from incomplete write results returned after a bulk write error. As described in that issue, I believe it's possible to calculate the map of inserted IDs that we expect to have completed successfully but it's a fair bit of work. |
| Comment by Jeremy Mikola [ 23/Apr/19 ] |
|
Is there another issue to cross-reference with this request for added context? This isn't terribly difficult to implement in a wrapping driver (e.g. PHP, Swift), as it's a matter of fetching the _id field from the document(s). Does mongolite provide no abstraction around libmongoc's own result objects? |