Start a new topic

Possible bug with collection access count

Using Collection Access' (http://devcenter.kinvey.com/rest/reference/business-logic/reference.html#collection-access-module) count() causes the error below. Was working before this.



{

"error": "BLRuntimeError",

"description": "The Business Logic script has a runtime error. See debug message for details.",

"debug": "TypeError: Cannot call method 'on' of undefined"

}

I also encountered this problem too. What's weird is that last week it worked perfectly, but now I didn't even change any of my code lately and I got that error too.
This was due to a software bug which has since been resolved. We apologize for the inconvenience.
I'm not sure if it's related, but I'm finding that collectionAccess.count() now (sometimes it seems) returns the count as an object rather than an integer as per the MongoDb documentation. i.e. in the code below I used to get response == and now I get: { count : }



(this is similar to a post I made earlier today that collectionAccess.findAndModify() now returns the entity wrapped in a .entity{} object rather than just the doc.



ca.collection('plus1').count(countQuery, function(err, response) {

if (err) {

callback("error getting count of plus1 objects for find: " + findId + " user: " + userId + ": " + JSON.stringify(err));

return;

} else {

logger.info("Delete: Counted plus1 for find: " + findId + " user: " + userId + ": " + response + " response as object; " + JSON.stringify(response));

updateFindCount(findId, response, callback);

}

})

Joel are you still seeing this? We patched this last week so it no longer returns an object.
I am seeing it right this moment and have been chasing it this morning. ;)

AppKey: kid_VPWDx2NteO



My workaround:

var integerResponse = typeof response === 'object' ? response.count ? response.count : 0 : response;



Is this the same issue as the 'findAndModify' ".entity{}" wrapper as well?



thx
Joel please let me know if this is still happening.



Thanks.
Thanks Michael. Seems to be fixed now.
Started to see this problem today in collectionAccess.remove() passing back the number removed items as an object { count : # }
Thanks - that should be resolved now as well. There was one edge case remaining where some of the values would not get returned properly.
Login or Signup to post a comment