如何在节点蒙古语上使用 dropIndex() ?
您好,我正在尝试删除 mongo db 中的特定输入...我正在使用 蒙古语 客户端,很抱歉我还没有掌握 API...
这次尝试失败了,
if(req.body.post.del){
posts.dropIndex({_id:req.body.post.del}, function(err){ //this query must be wrong
if(err)
res.render('blog_edit', {locals:{title:'Failure to delete from DB'}}); //this is what I get...
else
posts.find({}).toArray(function(err, arr){
if(err) throw err
res.render('blog_edit', {locals:{title:'Success!', posts: arr }});
})
})
}
请提供一些帮助... 提前致谢!
Hello I'm trying to delete a specific input in mongo db... I am using the mongolian
client, and I'm sorry I haven't managed to grasp the API yet...
this attempt is failing
if(req.body.post.del){
posts.dropIndex({_id:req.body.post.del}, function(err){ //this query must be wrong
if(err)
res.render('blog_edit', {locals:{title:'Failure to delete from DB'}}); //this is what I get...
else
posts.find({}).toArray(function(err, arr){
if(err) throw err
res.render('blog_edit', {locals:{title:'Success!', posts: arr }});
})
})
}
please provide some help...
thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我设法通过使用
remove
而不是dropIndex
来完成我想要的操作,但由于某种原因,无法通过_id
进行索引,因此我使用了 title :这不会工作:
Finally I managed to do what I wanted by using
remove
instead ofdropIndex
, still for some reason indexing by_id
was not possible so I used title:this will not work: