David Trinh David Trinh -5 years ago 202
Node.js Question

unable to fetch data from mongodb from results using streams/highland.js

I am new to streams and I am trying to fetch the data from my collection using reactive-superglue/highland.js (https://github.com/santillaner/reactive-superglue).

var sg = require("reactive-superglue")
var query = sg.mongodb("mongodb://localhost:27017/qatrackerdb").collection("test1")

exports.findAll = function (err, res) {
.done(function(data) {

my curl request:

curl -i -X GET http://localhost:3000/queries/

Answer Source

I'm not really sure what reactive-superglue is doing for you here. It looks like it's just a compilation of highland shortcuts for getting different data sources to respond.

You can use highland to do this directly like this:

var collection = sg.mongodb("mongodb://localhost:27017/qatrackerdb").collection("test1");
return h( collection.find({}) )
    .map(h.extend({foo: "bar"})

Edit: The above snippet still uses reactive-superglue, but you could just use the node mongo driver:

var url = 'mongodb://localhost:27017/qatrackerdb';
MongoClient.connect(url, function(err, db) {
  h( db.collection("test1").find({}) )
    .map(h.extend({foo: "bar"})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download