0

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

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

现在我不确定它是.,'还是? <p>等。

4

1 回答 1

0

我无法重现这一点。这是我在 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 的问题?(不幸的是,我不熟悉这个程序。)一个简单的故障排除方法是测试一次保存每个唯一字符,看看是哪个字符导致了问题。希望这可以帮助!

于 2012-04-11T15:12:24.280 回答