[SERVER-162] length on cursor returns a function, rather than calling a function Created: 17/Jul/09  Updated: 15/Aug/09  Resolved: 17/Jul/09

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

Type: Bug Priority: Minor - P4
Reporter: sandstrom Assignee: Eliot Horowitz (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS X 10.5


Participants:

 Description   

Both these two should return 0. The first one returns a function atm.

> db.events.find().length;
function () {
return this.toArray().length;
}
> db.events.find().toArray().length;
0



 Comments   
Comment by Eliot Horowitz (Inactive) [ 15/Aug/09 ]

closed since resolved 2+ weeks ago

Comment by Eliot Horowitz (Inactive) [ 17/Jul/09 ]

This is by design since we don't want people to think that a cursor is like an array. length is an expensive operation.
count() is fast, and is what should be used.

Generated at Thu Feb 08 02:53:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.