简体   繁体   中英

MongoDB: javascript execution failed : can't save a DBQuery object at src/mongo/shell/collection.js

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

In mongoDb shell i perform the following action :

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

when call to the save method the exception thow.

use var doc1 = db.users.findOne({name:"Harmeet"})

db.users.find returns a cursor.

虽然@Manuel Rony Gomes回答了这个问题,但是当你想要立即将从集合A中找到的多个文档插入到集合B中时,可以使用toArray()让它工作:

db.coll_B.insert(db.coll_A.find({}).toArray())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM