We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to do the following operation:
$query = new Lead; $query->select('_id','first_name','last_name', 'email', 'created_at') ->groupby('email') ->where('created_at', '>=', $startDate) ->where('created_at', '<', $endDate);
and then chunking because results are huge:
$chunkSize = 5000; $query->chunk($chunkSize, function($leads) use(&$postFields) { Log::info("Processing chunk..."); foreach($leads as $iLead => $lead) { // ... Do stuff with lead here ... } } Log::info("Query Complete!");
Getting the following error
RuntimeException in Aggregate.php line 168: invalid operator '$last' in Aggregate.php line 168 at Server->executeCommand('mission_control', object(Command), object(ReadPreference)) in Aggregate.php line 168 at Aggregate->execute(object(Server)) in Collection.php line 191 at Collection->aggregate(array(array('$match' => array('$and' => array(array('created_at' => array('$gte' => object(UTCDateTime))), array('created_at' => array('$lt' => object(UTCDateTime)))))), array('$group' => array('_id' => array('$last' => '$_id'), 'email' => array('$last' => '$email'), 'first_name' => array('$last' => '$first_name'), 'last_name' => array('$last' => '$last_name'), 'created_at' => array('$last' => '$created_at'))), array('$limit' => '5000'), array('$project' => array('_id' => '1', 'first_name' => '1', 'last_name' => '1', 'email' => '1', 'created_at' => '1'))), array('typeMap' => array('root' => 'array', 'document' => 'array'))) at call_user_func_array(array(object(Collection), 'aggregate'), array(array(array('$match' => array('$and' => array(array('created_at' => array('$gte' => object(UTCDateTime))), array('created_at' => array('$lt' => object(UTCDateTime)))))), array('$group' => array('_id' => array('$last' => '$_id'), 'email' => array('$last' => '$email'), 'first_name' => array('$last' => '$first_name'), 'last_name' => array('$last' => '$last_name'), 'created_at' => array('$last' => '$created_at'))), array('$limit' => '5000'), array('$project' => array('_id' => '1', 'first_name' => '1', 'last_name' => '1', 'email' => '1', 'created_at' => '1'))), array('typeMap' => array('root' => 'array', 'document' => 'array')))) in Collection.php line 42 at Collection->__call('aggregate', array(array(array('$match' => array('$and' => array(array('created_at' => array('$gte' => object(UTCDateTime))), array('created_at' => array('$lt' => object(UTCDateTime)))))), array('$group' => array('_id' => array('$last' => '$_id'), 'email' => array('$last' => '$email'), 'first_name' => array('$last' => '$first_name'), 'last_name' => array('$last' => '$last_name'), 'created_at' => array('$last' => '$created_at'))), array('$limit' => '5000'), array('$project' => array('_id' => '1', 'first_name' => '1', 'last_name' => '1', 'email' => '1', 'created_at' => '1'))), array('typeMap' => array('root' => 'array', 'document' => 'array')))) in Builder.php line 307 at Collection->aggregate(array(array('$match' => array('$and' => array(array('created_at' => array('$gte' => object(UTCDateTime))), array('created_at' => array('$lt' => object(UTCDateTime)))))), array('$group' => array('_id' => array('$last' => '$_id'), 'email' => array('$last' => '$email'), 'first_name' => array('$last' => '$first_name'), 'last_name' => array('$last' => '$last_name'), 'created_at' => array('$last' => '$created_at'))), array('$limit' => '5000'), array('$project' => array('_id' => '1', 'first_name' => '1', 'last_name' => '1', 'email' => '1', 'created_at' => '1'))), array('typeMap' => array('root' => 'array', 'document' => 'array'))) in Builder.php line 307
The text was updated successfully, but these errors were encountered:
This error occurs because you have selected _id field. Change it to this.
$query->select('first_name','last_name', 'email', 'created_at') ->groupby('email') ->where('created_at', '>=', $startDate) ->where('created_at', '<', $endDate);
Sorry, something went wrong.
What happens when we need the _id after we group the data. I have the same problem but I need the _id field on the result.
No branches or pull requests
Trying to do the following operation:
and then chunking because results are huge:
Getting the following error
The text was updated successfully, but these errors were encountered: