I want to be able to store objects as code in mongo DB.
the main problem is when trying to store an array that contain types..
Example: [String, Array, 'some', 'hello world'].
When saving and getting the document I would get
Doc.array = [undefined, undefined, 'some', 'hello world']
Is there a way to serialize the array it self and save it in mongo ? Something like:
var S = require('serializer');
var obj = {
cons: [[String, 'some', 'somemore']],
func: function(param, param2){
param2.some = 'bla';
}
};
var objs = S.serializer(obj);
//Store that serialized obj as a value for binary key or buffer key in mongo..
// then when getting the document...
var obj = S.deserialize(objs);
// being obj the exactly same object with the array and the function.
Is there a way to do this, or is there a different/better approach ?
Edit
I just need a way to store a nools rule, so the problem is that the rule constraints structure is the following:
[FactType, 'alias', 'conditions']
Where FactType could be String, Object, Custom.
Stringis (or rather, refers to) a function. What exactly do you want stored in Mongo for it?