0

コードの出力を取得したい

app.get('/_browse', function(req, res){

    var filter = {};
    var type = req.query["type"] || '';
    var nodeValue =  (req.query["nodeValue"]) ? req.query["nodeValue"] : "";
    var nodeApi =  (req.query["nodeApi"]) ? req.query["nodeApi"] : "";
    var node =  (req.query["node"]) ? req.query["node"] : "";
    var callback = req.query["callback"] || '';
    /*var mapobject = {
        kingdom : "phylum",
        phylum : "class",
        class : "order",
        order : "family",
        family : "genus",
        genus : "specificEpithet",

    };*/
    var text = {
            text: nodeValue,
            specimenCount: 'count',
            nodeApi: nodeApi,
            nodeValue: nodeValue,
                }

    var mapobject = {

        phylum : "family",
        family : "genus",
        genus : "specificEpithet",

    };
    var type = mapobject[nodeApi];  
    var nvalue = {};
    if(nodeValue != ''&& nodeApi != '') {
     nvalue[nodeApi] = nodeValue;
    }
    var typeValue = "$"+ type;

collection.aggregate(

        { $match : nvalue},
        { $group : {
            _id : typeValue,
            count : { $sum : 1 },
        }},
        {$sort: {_id: 1}},
    function(err, results) {
        /*results[0]['text'] = text;
        console.log("text values",results[0]['text']);*/
            /*var text = {
            text: "Aceraceae ",
            specimenCount: 'count',
            nodeApi: "Family",
            nodeValue: "Aceraceae",
                }
            results['text'] = text;
            console.log("text values",results.text);
            */  
        (var i in results){
            if(results = text){
                results.text =  nodeValue;
                results.specimenCount = 'count';
                results.nodeApi = nodeApi;
                results.nodeValue = nodeValue;
            console.log("results",results.text);
            }
        res.writeHead(200, {'Content-Type': 'application/json'});
        if (callback != '') {
            res.end(callback + '(' + JSON.stringify({success: true, rows: results}) + ')');

        } else {
                res.end(JSON.stringify({success: true, rows: results}));


            }

    });

}); 

お気に入り...

    results: [{
       text: "Acanthaceae (300)",
       specimenCount: "300",
       nodeApi: "Family",
       nodeValue: "Acanthaceae",
       filter: {
           StateProvince: "Louisiana",
           Taxonomy: "",
           Phylum: "dicot"
       }
   },

このようにコーディングしましたが、出力が得られません。この出力を行うには、結果を処理する必要があります。出力を取得するのを手伝ってください。

4

1 に答える 1