0

Here is Query in mongodb , where i used to get information on the basis of status, verify_status and their category as well as their Location, their is only one location for the field but need to find in multiple set of location.

Update : I try to run this query in Robo3t , it return blank Result but same query i run in Studio3t it shows expected Result. is there any version issue.

{
    "status":{
        "$eq":"Active"
    },
    "verify_status":{
        "$eq":"Yes"
    },
    "$or":[
    {
        "category":{
            "$eq":{
                "$oid": "5da0f71e15712b5f7723bb58"
            }
        }
    },
    {
        "multi_car_status":{

            "$eq":"ON"

        },
        "additional_category":{

            "$eq": "5da0f71e15712b5f7723bb58"

        }
    }
    ],
    "driver_location":{
        "$in":[
            "5dee787f15712b443f6a5e06",

            "5dee787f15712b443f6a5e06"
        ]
    }
}

When i removed the driver_location or "$or" its return resul.there are result in the db but it return return 0 result. i can't get the result with the both the operators. below is the sample data.

{
    "_id" : ObjectId("5ead0f5f15712b5df22d7e23"),

    "driver_location" : "5dee787f15712b443f6a5e06",

    "category" : ObjectId("5da0f71e15712b5f7723bb58"),

    "image" : "7f8e1ddfbe862a7ac4386b2f41fe953f.jpg",

    "driver_name" : "Ravi aa",

    "email" : "#####@gmail.com",

    "dail_code" : "+1",

    "mobile_number" : "83748746",

    "dob" : "10/05/2000",

    "password" : "######",

    "verify_status" : "Yes",

    "status" : "Active",

    "availability" : "Yes",

    "mode" : "Available",

    "gender" : "male",

    "vehicle_type" : null,

    "vehicle_maker" : "5da0f05115712b5fb36e3d02",

    "vehicle_model" : "5db22e1215712b25a36b8a3c",
   
   
    "loc" : {
        "lon" : 77.35124777,
        "lat" : 28.6543715
    },
    "address" : {
        "address" : "delhi",
        "county" : "United States",
        "state" : "AR",
        "city" : "delhi",
        "postal_code" : "122001"
    },
    "multi_car_status" : "ON",
    "additional_category" : [ 
        "5da09ed315712b413333ca58",
 
        "5da0f6fc15712b5c1956eed6", 

        "5da0f73b15712b5fb36e3d09"
    ],
   
   
}
  • Can you please update your question with more details, like row data, expected result and tried query, no one will help you without clarification of your question. you can learn https://stackoverflow.com/help/how-to-ask – turivishal Jul 31 '20 at 19:22
  • @turivishal thanks bro edit the question with some information. – ravi Kathait Aug 01 '20 at 17:55
  • HI @all i dont know the reason but due when i put the code in compress format Robo3t does not resturn any result. earlier i was used Robo 3t version then i try with studio3t then i find only differnce that compress code of json not working in Robo3t – ravi Kathait Aug 01 '20 at 21:07
  • Possibility you are executing query in different database, look at this query is working https://mongoplayground.net/p/eE34mKyI6ZB – turivishal Aug 02 '20 at 05:57

0 Answers0