I have an array of custom datatype such as a class or a structure and would like to store it in mongodb as binary data. How would I go about adding and retrieving that array from mongodb? I need to do this via the C++ driver. I was able to add and retrieve for simple arrays using appendbinData and getbinData but I can't find a way to do this for arrays of custom datatypes.
-
try serialization, such as msgpack, protobuf or json or xmlDmitry Ledentsov– Dmitry Ledentsov2014-01-16 18:40:55 +00:00Commented Jan 16, 2014 at 18:40
-
All of these require you to define a way to serialize the datatype. Though what I am using is a complex datatype from a library. Is it possible to just dump this data and extract without having to go through the code of the complex datatype and finding out ways to serialize each component?Marcus_Aurelius– Marcus_Aurelius2014-01-16 19:16:07 +00:00Commented Jan 16, 2014 at 19:16
-
For example the answer here.Marcus_Aurelius– Marcus_Aurelius2014-01-16 19:24:55 +00:00Commented Jan 16, 2014 at 19:24
-
you can dump anything you want, but in c++ you need to know the details of your type. You can help yourself with libraries to write as little boilerplate as possibleDmitry Ledentsov– Dmitry Ledentsov2014-01-16 20:52:28 +00:00Commented Jan 16, 2014 at 20:52
Add a comment
|