My mongodb table has a field which has object value like
_id : ObjectId("59ad227e191cc3a4c33ade07")
user_info : {"first_name": "Shraddha", "last_name": "Banerjee", "Zip": "90242", "City": "SantaBarbara"}
I want to find the users with Zip: 90242.
I tried doing it like:
$users = User::where('user_info.Zip','=', 90242)->get();
But this gives me empty result. How can this be achieved ?
it seems that your zip data is stored string and when you query it you are using integer.
$users = User::where('user_info.Zip','=', '90242')->get();
try to cast zip to string when you do the query