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
Post a Comment