MongoDB:javascript执行失败:无法在src / mongo / shell / collection.js中保存DBQuery对象 [英] MongoDB: javascript execution failed : can't save a DBQuery object at src/mongo/shell/collection.js

查看:288
本文介绍了MongoDB:javascript执行失败:无法在src / mongo / shell / collection.js中保存DBQuery对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MongoDb中,当我尝试修改集合中的现有文档时,它会生成以下异常: javascript执行失败:无法在src / mongo / shell / collection.js中保存DBQuery对象

In MongoDb , when i try to modify existing document in collection , it generate the following exception : javascript execution failed : can't save a DBQuery object at src/mongo/shell/collection.js

在mongoDb shell中,我执行以下操作:

In mongoDb shell i perform the following action :

 > var doc1 = db.users.find({name:"Harmeet"})
 > doc1.color = "Blue"
 > db.users.save(doc1)

当调用save方法时异常thow。

when call to the save method the exception thow.

推荐答案

使用
var doc1 = db.users.findOne({name:Harmeet})

db.users.find 返回游标。

这篇关于MongoDB:javascript执行失败:无法在src / mongo / shell / collection.js中保存DBQuery对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆