(节点:5700)不赞成使用警告:猫鼬:mpromise(猫鼬的默认诺言库),请插入您自己的诺言库

时间:2019-01-25 09:01:13

标签: javascript node.js mongodb

我收到此警告:DeprecationWarning:猫鼬:mpromise(猫鼬的默认诺言库)已过时,请插入您自己的诺言库。我在后端路线上尝试在MongoDb中的模型上执行.find时遇到此错误。我不确定这意味着什么或如何解决。

下面我显示了导致此错误的正在调用的路由。我很抱歉,我通常并不了解诺言,我不确定“妥协”是什么意思。

app.get(“ / search / search =:search&location =:location?”,功能(要求,要求){     console.log(“我在首页搜索后端”)

console.log(req.params.search);
console.log(req.params.location);

var resultObj = {
    search: req.params.search,
    location: {},
    results: []
}

if (req.params.location) {


    var apiKey = "AIzaSyBejz2PGLk2-SG6MI6FCEmyaCQG-7pPuuw"
    var query = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + req.params.location + "&key=" + apiKey;
    var query2 = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=" + req.params.location + "&destinations=&key=" + apiKey;
    request(query, function (error, response, body) {
        if (!error && response.statusCode === 200) {
            // console.log(results)

                resultObj.location = JSON.parse(body).results;
                // resultObj.location = body
                var geo = resultObj.location[0].geometry.location
                console.log("I requested google maps api");
                console.log(geo);

            // $near: [geo.lat, geo.lng]



            Item.find({
                // $text: { $search: req.params.search }, 
                'geometry.coordinates': {
                    $geoWithin: {
                        $center: [[geo.lng, geo.lat], 20 / 3963.2 ]
                    }

                }



            })
                .populate('properties.itemReviews')
                // .skip(20)
                .limit(5000)

                .exec(function (err, results) {

                    if (err) {
                        console.log("searching users by location was not successful");
                        console.log(err);
                        res.json({ failedLocation: "This location does not exist" })
                    } else {
                        console.log("ive successfully searched users by location, below is results");
                        console.log(err)
                        console.log(results);
                        resultObj.geoResults = results
                        resultObj.finalResults = [];
                        resultObj.geo = geo;
                        res.json(resultObj)
                    }
                });

            } else {
                res.json({ error: "There was an error with your address" });
            }


    });



} else {
    res.json(resultObj);

}

});

我的代码正在工作,我只是担心过时的弃用会在我的代码中造成问题。如果没有什么可担心的,请告诉我!

1 个答案:

答案 0 :(得分:1)

在已定义mongoose.connect()方法的server.js文件中。在其上方添加。

05_celery_tasks_run: /usr/bin/env bash does not exist.