I am using SpagoBI with MongoDB. like mentioned in the link [1] I can use script .js on my MongoDB data base to get results. What I need to do is to merge the two following queries results:
var query1=db['cygnus_/kurapath_enocean_switch2a_enocean'].find().sort({ recvTime : -1 }).limit(1) ;
var query2 = db['cygnus_/kurapath_enocean_switch2b_enocean'].find().sort({ recvTime : -1 }).limit(1);
If I put something like
var query= query1 + query2;
I got the error:
query has no method 'forEach' at serializeResult
Any ideas how to do that? Thanks in advance for your help!
[1] http://wiki.spagobi.org/xwiki/bin/view/spagobi_server/data_set
Try
What happens here is that
toArray()
is used to convert the result cursors into standard Javascript arrays of documents (in this case arrays with just one entry because you usedlimit(1)
). Then the standard Javascript array methodconcat
is used to append one array to the other and store it in the new arrayresults
.That array can then be used as you want.