问题是,我的控制台出现错误:
{ [MongoError: $regex has to be a string]
name: 'MongoError',
message: '$regex has to be a string',
waitedMS: 0,
ok: 0,
errmsg: '$regex has to be a string',
code: 2 }
Run Code Online (Sandbox Code Playgroud)
基本上,我使用 Ajax 从我的 MongoDB 中获取数据,我在其中搜索用户。没有 Ajax,我的搜索功能可以正常工作,但我想搜索用户而不需要刷新网页,只需填写我的 HTML。这是我的所有代码:
服务器代码:
app.post("/searchresult", function(req, res){
var thename = req.body.thename;
LoginUser.find({
$or: [
{"firstname": {$regex: thename, $options: 'i'}},
{"lastname": {$regex: thename, $options: 'i'}}
]
}, function(err, searchedUser){
if(err){
console.log(err);
res.redirect("back");
} else {
res.render("searchprofile", {foundUser: searchedUser});
}
});
});
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<form class="form-inline" id="searchform" …Run Code Online (Sandbox Code Playgroud) 您好,我目前正在开发一个 MEAN 堆栈项目,我发现了在部署项目之前推荐的 Nodejs 集群模块。
我已经应用了它并做了一些 ApacheBenchmark,问题是,它只响应 1 个工作人员,它不会围绕我的其他 7 个工作人员轮换。
我在谷歌上搜索过这个问题,是的,Windows 默认不能进行循环,但是有没有办法在 Windows 中启用循环?
谢谢你!