'MongoDB execute script returns _mongo and _db information
I'm executing a MongoDB script via the Kohana MangoDB ORM.
Here's the code to be executed:
var query {
date: date
};
var indexes = db.organisation_booking_indexes.find(query);
If I do .findOne(query) I get the specific result as an array. However just doing .find(query) returns other stuff like _mongo and _db instead of an array of the expected results.
How do I return just the documents I'm looking for?
Solution 1:[1]
It appears that some objects can't be returned "as is" using JS. In this case Mongo return the Cursor
Try:
var indexes = db.organisation_booking_indexes.find(query).toArray();
This will convert the result in a "compatible" object. Take a look at this post to get more details: MongoDB: Error executing stored JavaScript function
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
