protected function resolvePrimaryIdByPipeline(array $pipeline) {
		foreach ($pipeline as $stage) {
			foreach ($stage as $name => $definition) {
				if ($name === '$group' && isset($definition['_id'])) {
					return ltrim($definition['_id'], '$');
				}
			}
		}
	}
protected function resolvePrimaryIdByPipeline(array $pipeline) {
		foreach ($pipeline as $stage) {
			foreach ($stage as $name => $definition) {
				if ($name === '$group' && isset($definition['_id'])) {
					return ltrim($definition['_id'], '$');
				}
			}
		}
	}
protected function resolvePrimaryIdByPipeline ( array $ pipeline ) { foreach ( $ pipeline as $ stage ) { foreach ( $ stage as $ name => $ definition ) { if ( $ name === '$group' && isset ( $ definition [ '_id' ] ) ) { return ltrim ( $ definition [ '_id' ] , '$' ) ; } } } }
Resolve the primary ID by aggregation pipeline definition

@param  array $pipeline
@return string | null
Resolve the primary ID by aggregation pipeline definition