I'm trying to retrieve a stored function from 'system.js' and use it in mapReduce.
When I retrieve and print the document that defines the function it is correct. However, when I try to extract the 'value' field (BSON_CODE) the JavaScript code is lost in the conversion.
Document returned from database:
mongo.bson.print(result)
_id : 2 mapVarType
value : 13 BSON_CODE: function() {
if ( (this.doctype == "vcf_variant") &&
(typeof this.other.var_type != "undefined" ))
{
emit( this.other.var_type, 1);
}
}
Extract 'value' field (hm, looks empty?):
mongo.bson.value(result, "value")
[1] ""
attr(,"class")
[1] "mongo.code"
Looking at the structure, 'chr' is empty:
str(mongo.bson.value(result, "value"))
Class 'mongo.code' chr ""
It should look like this one.
js_function <- mongo.code.create( ' ' )
str(js_function)
Class 'mongo.code' chr "function () {if ( (this.doctype == "vcf_variant") && (typeof this.other.var_type != "undefined" )) {emit( this.other.var_ty"| truncated
I've tried a few different things, including converting the bson to a list first using 'mongo.bson.to.list(result)'. The results are the same, it is empty.
I'm trying to retrieve a stored function from 'system.js' and use it in mapReduce.
When I retrieve and print the document that defines the function it is correct. However, when I try to extract the 'value' field (BSON_CODE) the JavaScript code is lost in the conversion.
Document returned from database:
Extract 'value' field (hm, looks empty?):
Looking at the structure, 'chr' is empty:
It should look like this one.
I've tried a few different things, including converting the bson to a list first using 'mongo.bson.to.list(result)'. The results are the same, it is empty.