我正在寻找使用NodeJS从数据库动态获取值的方法
我现在正在做的是,我正在采用硬编码的价值观。
注意:
$ text :集合索引。
db.collection('Questions').find({$text: {$search: typed}}, {projection: { _id: 0, "How": 1, "Where": 1, "Who Approves": 1, "Applied Extra": 1, "Inform Personally": 1, "Pre Planning": 1, "Types": 1}}).toArray(function(err, result) {
if (err)
console.log(err);
if (typed.trim() == "How To Apply") {
var responding_how = JSON.stringify(result).substring(JSON.stringify(result).indexOf("How") + 6, JSON.stringify(result).indexOf("You Want Off On.") + 15)
console.log("How To Apply - " + responding_how);
res.send(responding_how);
}
if (typed.trim() == "Where To Apply") {
var responding_where = JSON.stringify(result).substring(JSON.stringify(result).indexOf("https://"), JSON.stringify(result).indexOf("Who Approves") - 3)
console.log("Where To Apply - " + responding_where);
res.send("<a target='_blank' href=" + responding_where + ">Apply off</a>");
}
答案 0 :(得分:0)
创建一个新集合,使其包含所有“标题”,您可以将其称为Projections。 查询该集合(find({}))。 将查询响应(在异常检查之后)发送到问题“查找”查询:
ViewModel vm = mainwindow.DataContext as ViewModel;
string selected = vm.cboVideoQuality_SelectedItem;
if (selected == "High")
{
// ...
}
我希望这就是你的意思。