[SERVER-13668] Returning WriteResult from eval fails Created: 21/Apr/14  Updated: 06/Dec/22  Resolved: 02/Jul/18

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: 2.6.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Backlog - Security Team
Resolution: Done Votes: 0
Labels: bulk_api
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Server Security
Operating System: ALL
Participants:

 Description   

When you run something like this it fails to deserialize the WriteResult on the client (shell):

> db.eval(function(){return db.nothing.update({fake:1},{$set:{a:1}})})
2014-04-21T08:56:42.415-0400 ReferenceError: writeConcern is not defined
> var res = db.eval(function(){return db.nothing.update({fake:1},{$set:{a:1}})})
>s res.nInserted
0
> res.tojson()
2014-04-21T08:58:49.077-0400 ReferenceError: singleBatchType is not defined
 
// converting to json from WriteResult works much better.
> db.eval(function(){return db.nothing.update({fake:1},{$set:{a:1}}).tojson()})
{ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 }

This is probably due to the fact that most of the types are defined in an enclosure and not public, but more investigation should be done.



 Comments   
Comment by Sara Golemon [ 02/Jul/18 ]

Closing this issue as "Gone Away" since db.eval() has now been removed from MongoDB.

Generated at Thu Feb 08 03:32:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.