我试图从循环中获取mongoose的记录.但它没有按预期工作.我有一系列带有问题和答案的哈希,我正试图从我的数据库中找到这些问题.这是我的循环:
for (var i=0;i < answers.length;i++)
{
console.log(i)
var question_ans = eval('(' + answers[i]+ ')');
var question_to_find = question_ans.question.toString()
var ans = question_ans.ans.toString()
console.log(ans)
quiz.where("question",question_to_find).exec(function(err,results)
{
console.log(results)
if (ans == "t")
{
user_type = results.t
}
else if (ans == "f")
{
user_type=results.f
}
})
}
Run Code Online (Sandbox Code Playgroud)
和终端的结果是这样的:
0
t
1
f
[ { question: 'i was here',
_id: 5301da79e8e45c8e1e7027b0,
__v: 0,
f: [ 'E', 'N', 'F' ],
t: [ 'E', 'N', 'F' ] } ]
[ { question: 'WHo r …Run Code Online (Sandbox Code Playgroud) 我目前正面临一个需要帮助的问题.我正在网站上为我的内容创建一些网址.网站用户可以将其发布在Facebook上的群组页面上.我想计算这些帖子的点击次数.我尝试使用php函数,但该函数的计数和fb见解(达到的人数)是非常不同的.(fb洞察力显示我的数据量减少3倍)为什么这个数量不同?如果我想要fb人们获取数据我怎么能得到它作为用户将发布的页面不是我的.
问候