The original code took whatever string it got from $record, which was usually incomplete, and immediately tried to insert that via MongoDB command. My solution concatenates each $record into $aggRecord and then inserts the complete $aggRecord via MongoDB command.
The original code took whatever string it got from
$record
, which was usually incomplete, and immediately tried to insert that via MongoDB command. My solution concatenates each$record
into$aggRecord
and then inserts the complete$aggRecord
via MongoDB command.