0
我有視頻模式(水線)高級申請(帆的NodeJS)
視頻
-title
-description
-matches (array)
[0]
- MatchTitle
- MatchDescription
[1]
...
[N]
我如何才能找到其中包含匹配標題爲「ABC」,例如視頻?
我寫的不是最好的解決方案,因爲它是從數據庫retrive所有數據
Video.find({is_html5:true}).done(function(err, videos) { // get all videos
async.forEach(videos, function(video, callback) {
var isFound = false;
async.forEach(video.matches, function(videoMatch, matchCallback) { // get video matches
if(videoMatch.gs_id === match.gs_id && !isFound) {
match.relatedVideos.push(video.id);
isFound = true;
}
matchCallback();
}, function(err3) {
callback();
});
}, function(err2) {
cb();
});
}, function(err1) {
cb();
});