我需要找一张名字的照片。照片的名称可以包含几个单词。问题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});
});
});
};