javascript - check if object is a mongo cursor -


i have method in want either receive list or mongo cursor , react that, example:

createfromtemplate: function(template) {   var iter;   if(template instanceof mongo.cursor) {     iter = template.fetch();   } else if(template instanceof array) {     iter = template;   } else {     throw new meteor.error(500, 'template must cursor or array');   } } 

however, seems return false when don't expect it

> var p = pagetemplates.find();  // mongo cursor > var parray = p.fetch();        // array > object.prototype.tostring.call(p); [object object] > typeof p object > p instanceof mongo.cursor false 

how can tell if object mongo cursor?

you should able use instanceof mongo.collection.cursor (not mongo.cursor). console:

> = meteor.users.find() <- localcollection.cursor {collection: localcollection, sorter: null, _selectorid: undefined, matcher: minimongo.matcher, skip: undefined…} > instanceof mongo.collection.cursor <- true 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -