javascript - MongoDB query is JSONArray instead JSONObject -


i want select whole document , send jsonobject.

app.post('/getinvbykost', function(request, response){      var tablename = request.body.tablename;      move.find({tablename: tablename}, function(err, doc) {         response.json(doc);     });  }); 

this gives correct result "[]" ->array , not {} ->jsonobject. btw: got same issue move.aggregate(pipeline, function(err, res) {...

result:

[   {     stuff     } ] 

there function $unwind dont it....

in case since want 1 result, findone method more appropriate.

app.post('/getinvbykost', function(request, response){      var tablename = request.body.tablename;      move.findone({tablename: tablename}, function(err, doc) {         response.json(doc);     });  }); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -