$and in Mongodb

Hi,

Can you please suggest me whether the below syntax correct ? "$and" is not working in Mongodb Query.

            $general = [[ '$and' => [[ "user_id" => $input['user_id']],[ "type" => $type ]]]];
            $object = Profile::findFirst($general);

Please suggest me on the same.

Raja K



1.0k

I'm not much experienced in Mongo, but don't you need just this?

$general = [[ 'user_id' => $input['user_id'], 'type' => $type ]];
$object = Profile::findFirst($general);


3.9k

Hi,

Thanks. Let me test it again and get back to you .

Raja K