I am developing a project using GridFS to save large files as binary blob into MongoDB; I am using C++ API;
So far I am able to save large files into bucket, which in mongosh gives me two collections fs.chunks and fs.files;
However, I have problems to delete files from the bucket. I tried to use the C++ API and below are the code snip I am using:
# code that successfully assign "doc" as bsoncxx::v_noabi::document::view&
bucket.delete_file(doc["_id"].get_oid().value.to_string());
or
bucket.delete_file(doc["_id"].get_oid().value);
or even
bucket.delete_file(doc["_id"].get_oid());
None of the above code allow me to compile my code, error message always says
error: no matching function for call to ‘mongocxx::v_noabi::gridfs::bucket::delete_file(bsoncxx::v_noabi::document::view&)’
or similar input type not match delete_file() input variable.
I looked the official document says that the delete_file() accept and input variable “id” can be the type of
[bsoncxx::v_noabi::types::bson_value::view
which means anything in BSON;
But even I tried to convert the oid to a bson_value object does not fix the problem. I suspect there could be some bugs in the function? And I would like to seek help or advice from community. Thanks again.