从 mongoDB 中删除文档

编程入门 行业动态 更新时间:2024-10-21 07:41:54
本文介绍了从 mongoDB 中删除文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这可能是一个非常愚蠢的问题,但我是 MongoDB 的新手,所以请耐心等待.我创建了一个独立的 ruby​​ 类:

This might be a really stupid question, but I'm new to MongoDB, so bear with me. I've created a stand alone ruby class:

require 'rubygems' require 'mongo' require 'bson' require 'mongo_mapper' MongoMapper.database = "testing" class Twit include MongoMapper::Document key :id, Integer, :unique => true key :screen_name, String, :unique => true ...

然后我用 irb 执行以下操作

Then I do the following with irb

>> twit = Twit.all.first => #<Twit _id: BSON::ObjectId('4df2d4a0c251b2754c000001'), id: 21070755, screen_name: "bguestSB"> >> twit.destroy => true >> Twit.all => [#<Twit _id: BSON::ObjectId('4df2d4a0c251b2754c000001'), id: 21070755, screen_name: "bguestSB">]

那么如何销毁MongoDB中的文档呢?我做错了什么?

So how do I destroy documents in MongoDB? What am I doing wrong?

推荐答案

感谢大家对这个问题的帮助.对于其他遇到此问题的人,我相信这是因为我忘记将 mongodb 二进制文件的位置添加到 $PATH 变量

Thanks for all the help on this issue. For anyone else who has this problem, I believe it is because I forgot to add the the location of the mongodb binary files to the $PATH variable

在我的情况下,在 /usr/local/mongodb/bin 中安装了二进制文件,因此我需要添加 export PATH=/usr/local/mongodb/bin:$PATH 到我的 ~/.bash_profile

In my case installed the binary files in /usr/local/mongodb/bin as such I needed to add export PATH=/usr/local/mongodb/bin:$PATH to my ~/.bash_profile

更多推荐

从 mongoDB 中删除文档

本文发布于:2023-11-22 20:40:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1618938.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文档   mongoDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!