Skip to content

MongoDb Query Builder argument 1 issue #1323

New issue

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

Closed
haridarshan opened this issue Oct 9, 2017 · 0 comments
Closed

MongoDb Query Builder argument 1 issue #1323

haridarshan opened this issue Oct 9, 2017 · 0 comments

Comments

@haridarshan
Copy link

Hi,

as mentioned in #955 It did work but I have a use case where am fetching data from Mongo and fetch some values from Sql db and in fetched Mongo am updating the value. When doing so, am getting this error

Argument 1 passed to Jenssegers\Mongodb\Query\Builder::__construct() must be an instance of Jenssegers\Mongodb\Connection, instance of Illuminate\Database\MySqlConnection given, called in /var/www/app/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Eloquent/Model.php on line 399

Here is what am doing

/**
* Get all running live streams
*/
$getAllLiveStreams = LiveVideoStream::where([
	'status' => 'live'
])->get();

if (! $getAllLiveStreams->isEmpty()) {
	foreach ($getAllLiveStreams as $liveStream) {
		/**
		* Get all subscribed user for topic
		*/
		$getAllSubscribedUserCount = SubscribedUser::select('client_id')->where([
			'topics' => $liveStream->mqtt_topic
		])->count();
		
		/**
		* Save this count in LiveVideoStream
		*/
		$liveStream->live_viewers = $getAllSubscribedUserCount;
		try {
			$liveStream->save();
		} catch (\Throwable $exception) {
			// do nothing	
		}
	}
}

LiveVideoStream model is extending Jenssegers\Mongodb\Eloquent\Model and SubscribedUser model is extending Illuminate\Database\Eloquent\Model

Note: when using this in composer.json am getting above mentioned error

"illuminate/database": "5.4.*",
"illuminate/events": "5.4.*",
"jenssegers/mongodb": "*"

but if replace with this - no error

"illuminate/database": "5.2.43",
"illuminate/events": "5.2.43",
"jenssegers/mongodb": "3.0.0"

Am really stucked with this. Cannot update composer with latest stable release of both components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants