I’m currently trying to write C++ code with which I can store and retrieve blobs (binary large objects) into my database.
So far, I successfully wrote regular arrays, but I have doubts about whether they are stored in a dense form. Or am I mistaken here and I could simply write an array with the data being encoded in some integer type and be done with it?
I took a look at
bsoncxx::types::b_binary, but the documentation is a little bit short.
So far, I managed to find no example or tutorial that deals with blobs.
In my case in particular, amongst other things, I need to store the data from PNG images in the database. What is the best practice for that?
If possible, I’d like some basic example code that goes from having the binary data in some reasonable form (like
vector<uint8_t>) and declaring some appropriate builder to a finished
I’d also be interested in the best practice of retrieving the value, especially how to have the least copy operations in order to arrive at the binary data being in the original form as above.
But in any case, any sort of help would be appreciated.
(Note that I just began using mongocxx and MongoDB in general, and not completely familiar with the full terminology.)