【问题标题】:MongoDB not allowed to save in RockmongoMongoDB 不允许保存在 Rockmongo 中
【发布时间】:2012-04-10 23:53:18
【问题描述】:

我使用 Rockmongo 作为 UI,我正在尝试保存与此类似的内容。

text text's text. <p>text this is where the text goes</p><h1>haha</h1>

现在我不确定是.,' 还是? &lt;p&gt; 等。

【问题讨论】:

  • 可能是',尝试用反斜杠转义它。并尝试使您的问题更清楚!你有什么错误吗?
  • 由于缺少minimal reproducible example,因此应暂停。

标签: html json mongodb rockmongo


【解决方案1】:

我无法重现这一点。这是我在 JavaScript shell 中尝试的:

> db.text.save({_id:1, text:"text text's text. <p>text this is where the text goes</p><h1>haha</h1>"})
> db.text.find()
{ "_id" : 1, "text" : "text text's text. <p>text this is where the text goes</p><h1>haha</h1>" }

该行已成功保存。您是否用双引号括住文本字符串 " ?正如 bfavaretto 所提到的,问题可能来自您的字符串中的单个撇号。以下将不起作用:

> db.text.drop()
true
> db.text.save({_id:1, text:'This is text with an extra ' apostrophe.'})
... 
... 
> db.text.find()
> 

如您所见,上面的文档没有保存,因为字符串格式不正确。事实上,JS shell 甚至从未执行过该命令。

Mongo 应该能够保存包含所有这些字符的字符串。如果您仍然有问题,也许这可能是 RockMongo 的问题? (不幸的是,我不熟悉这个程序。)一种简单的故障排除方法是测试一次保存每个唯一字符,并查看哪个字符导致问题。希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多