0

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?

Braiam
  • 1
  • 11
  • 47
  • 78
iamjonesy
  • 24,732
  • 40
  • 139
  • 206

1 Answers1

2

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

Community
  • 1
  • 1
Julien
  • 21
  • 2