我正在从MongoDB检索数据。
var newFolderObj = { "created_by": String(email), "file_name": String(folderNameToSearch)}
Logger.printLog("")
dbs.collection("uploads").findOne(newFolderObj, function (err, result) {
console.log(result);
console.log('Result from mongo');
if (result == null) {
console.log('No user found');
res.statusCode = 404;
res.send({ msg: "No user found", success: false, statusCode: 404 });
return;
}
});
当我直接给电子邮件和file_name({“ created_by”:“ Randrm@email.com”,“ file_name”:“ randomFile”})提供值时,MongoDB将给出预期的结果。如果将其替换为var以进行动态检索,则结果为空。不知道该怎么办。有人可以帮我吗?