【问题标题】:Displaying result in formatted way in MongoDB在 MongoDB 中以格式化方式显示结果
【发布时间】:2017-01-26 23:56:03
【问题描述】:

一种以格式化方式显示结果的方法是 pretty() 方法。但是,我有 方法 pretty() 出现以下错误

db.mycol.find().pretty()

{

... "title":"MongoDB 不是 sql 数据库",

... "by":"教程点",

... "url":"http://www.tutorilaspoint.com",

...“标签”:[“mongodb”,“数据库”,“NoSQL”],

...“喜欢”:“100”

... }

2016-09-19T16:31:34.779+0545 SyntaxError: Unexpected token :

【问题讨论】:

  • 提供您的代码
  • 它与教程点的代码相同 >db.mycol.find().pretty() { "_id": ObjectId(7df78ad8902c), "title": "MongoDB Overview", "description": " MongoDB是没有sql数据库", "by": "教程点", "url": "tutorialspoint.com", "tags": ["mongodb", "database", "NoSQL"], "likes": "100 " } >
  • 应该是pretty() 而不是preety()
  • db.mycol.find().pretty() > { ... "title":"MongoDB is no sql database", ... "by":"tutorials point", .. . "url":"tutorilaspoint.com", ... "tags":["mongodb","dtabase","NoSQL"], ... "likes":"100" ... } 2016-09- 19T16:31:34.779+0545 SyntaxError: 意外令牌:

标签: mongodb


【解决方案1】:

你是说db.mycol.find().pretty()吗?

【讨论】:

  • 当您的集合不存在并且 find() 的链中断时,它应该会出错。但除此之外我没有任何线索。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-19
  • 1970-01-01
  • 1970-01-01
  • 2016-02-11
  • 1970-01-01
  • 2019-07-09
相关资源
最近更新 更多