node.js - Check if bulk is empty in mongoDB -
is there way check if mongodb bulk has operations before calling .execute() on it? pretty sure don't send empty objects insert keep getting error on 1 document
invalid operation, no operations in bulk
here code:
bulk.find({"acctsessionid":insert['acctsessionid']}).upsert().update({$set:insert});
and insert object looks this
{ acctstatustypeu: '3', acctsessionid: '1183628512-105130252', h323setuptimeu: '<sip:27117929995@41.66.146.252>', h323connecttimeu: sun mar 08 2015 19:30:37 gmt+0100 (cet), acmesessionegressrealmu: '620', acmesessioningressrealmu: 'core_psx' }
i see objects inserted still error. way nodejs driver talking , using unorderedbulkop insert documents.
i run same problem. check bulk.length
if (bulk.length > 0) { // run bulk operations }