在现场搜索几个单词?

时间:2018-06-07 08:57:14

标签: javascript node.js mongodb express

我需要找一张名字的照片。照片的名称可以包含几个单词。问题split。如何申请join?如何正确实现搜索?

<form class="search-form" action="/search-form" method="post">
   <input class="search-input" type="search" value="" name="search"                                id="inputSearch">
       <label for="search" class="search-label">
         <img src="#"  alt="search_icon" >
       </label>
</form>
 app.post('/search-form', function (req, res) {
        var titlePhoto = req.body.search;
        var tp = titlePhoto.split(' ');

        Photo.find({titlePhoto: {$in: tp}}, function (err, photos) {
             res.render('index.ejs', {photoList: photos});
        });
    });
};

0 个答案:

没有答案