0
我試圖搜索mongo集合來檢索一些基於變量名稱的值,像這樣 sportName =「/ Basketball/i」;mongo搜索變量名稱
db.Team.find({name:sportName}).forEach(function (team) {
print(team.name);
});
它總是返回任何結果,雖然當我搜索使用下面的腳本返回結果
db.Team.find({name: /Basketball/i}).forEach(function (team) {
print(team.name);
});
感謝
謝謝,我也發現這個很好用 {「sportName」:{'$ regex':'Basketball',$ options:'-i'}} – muhamadto 2012-02-17 06:09:11