Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-65323

when we are trying to use $ifnull inside $cond we r getting exat oposite result

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Critical - P2 Critical - P2
    • None
    • None
    • None
    • None

    Description

      [
      {
      '$match': {
      'seatNo':

      { '$exists': true }

      }
      },

      { '$unwind': '$allowedFor' }

      , {
      '$project': {
      '_id': 0,
      'roomNo': 1,
      'seatNo': 1,
      'status': 1,
      'allowedFor': 1,
      'startTime': {
      '$cond': [

      { '$ifNull': [ '$allowedFor.startTime', false ] }

      , true, false
      ]
      }
      }
      }
      ]

      sample data = [{
      "_id":

      { "$oid": "624e746b202bbc012c609cdd" }

      ,
      "eNo": "0183",
      "examCode": "E001",
      "age": "03-15-1993",
      "cat1": "Devloper",
      "cat2": "Delhi",
      "dob": "1993-03-15T00:00:00.000Z",
      "email": "jibanjyoti444222@gmail.com",
      "examName": "DEMO",
      "gender": "Male",
      "isPWD": false,
      "name": "Jiban jyoti Dhal",
      "password": "a123456",
      "phone": 7008583514,
      "registerOn": "2022-04-05T17:26:45.000Z",
      "sUid": "5df5249496e2a95ad3317ff9959c24",
      "shaPassword": "a123456",
      "allowedFor": [

      { "allowed": true, "mappedOn": "2022-04-05T17:27:27.000Z", "attended": false, "subCode": "S001", "slotId": "Slot-1" }

      ],
      "imageDownloaded": true,
      "imageDownloadedOn":

      { "$date": "2022-04-07T10:49:40Z" }

      ,
      "imageUrl": "candidateImage/5438.jpg",
      "ip": "192.168.96.125",
      "isFaceAuthMatched": false,
      "roomNo": 3,
      "seatNo": "3-5",
      "sitAssignedBy": "satya",
      "sitAssignedOn":

      { "$date": "2022-04-07T05:59:33.320Z" }

      ,
      "status": "socketDisconnected"
      },{
      "_id":

      { "$oid": "624e746b202bbc012c609cde" }

      ,
      "eNo": "5438",
      "examCode": "E001",
      "age": "09-01-1980",
      "cat1": "Scientist-G",
      "cat2": "Delhi",
      "dob": "1980-08-31T23:00:00.000Z",
      "email": "rkskrishna@gmail.com",
      "examName": "DEMO",
      "gender": "Male",
      "isPWD": true,
      "name": " R K Sahoo",
      "password": "a123456",
      "phone": 8280000062,
      "registerOn": "2022-04-05T17:26:45.000Z",
      "sUid": "e59910f481d8e83a2d917ff9959c25",
      "shaPassword": "a123456",
      "allowedFor": [
      {
      "allowed": true,
      "mappedOn": "2022-04-05T17:27:27.000Z",
      "attended": true,
      "subCode": "S001",
      "slotId": "Slot-1",
      "isSmartlockEnable": "Yes",
      "startTime":

      { "$date": "2022-04-07T11:37:16Z" }

      ,
      "newSetNo": 1,
      "assignQuestionlist": [
      "E001S001SEC-16",
      "E001S001SEC-11",
      "E001S001SEC-13",
      "E001S001SEC-15",
      "E001S001SEC-17"
      ],
      "endTime":

      { "$date": "2022-04-07T11:37:29Z" }

      }
      ],
      "imageDownloaded": true,
      "imageDownloadedOn":

      { "$date": "2022-04-07T10:49:40Z" }

      ,
      "imageUrl": "candidateImage/5438.jpg",
      "ip": "192.168.96.125",
      "isFaceAuthMatched": false,
      "roomNo": 3,
      "seatNo": "3-6",
      "sitAssignedBy": "satya",
      "sitAssignedOn":

      { "$date": "2022-04-07T05:59:33.320Z" }

      ,
      "status": "socketDisconnected"
      },{
      "_id":

      { "$oid": "624ed7359834c764f37217ac" }

      ,
      "eNo": "5439",
      "examCode": "E001",
      "age": "09-01-1980",
      "cat1": "Scientist-G",
      "cat2": "Delhi",
      "dob": "1980-08-31T23:00:00.000Z",
      "email": "rkskrishna@gmail.com",
      "examName": "DEMO",
      "gender": "Male",
      "isPWD": true,
      "name": " R K Sahoo",
      "password": "a123456",
      "phone": 8280000062,
      "registerOn": "2022-04-05T17:26:45.000Z",
      "sUid": "e59910f481d8e83a2d917ff9959c25",
      "shaPassword": "a123456",
      "allowedFor": [
      {
      "allowed": true,
      "mappedOn": "2022-04-05T17:27:27.000Z",
      "attended": true,
      "subCode": "S001",
      "slotId": "Slot-1",
      "isSmartlockEnable": "Yes",
      "startTime":

      { "$date": "2022-04-07T11:37:16Z" }

      ,
      "newSetNo": 1,
      "assignQuestionlist": [
      "E001S001SEC-16",
      "E001S001SEC-11",
      "E001S001SEC-13",
      "E001S001SEC-15",
      "E001S001SEC-17"
      ]
      }
      ],
      "imageDownloaded": true,
      "imageDownloadedOn":

      { "$date": "2022-04-07T10:49:40Z" }

      ,
      "imageUrl": "candidateImage/5438.jpg",
      "ip": "192.168.96.125",
      "isFaceAuthMatched": false,
      "roomNo": 3,
      "seatNo": "3-8",
      "sitAssignedBy": "satya",
      "sitAssignedOn":

      { "$date": "2022-04-07T05:59:33.320Z" }

      ,
      "status": "socketConnected"
      }]

      Problem Statement/Rationale

      What is going wrong? What action would you like the Engineering team to take?

      Steps to Reproduce

      How could an engineer replicate the issue you're reporting?

      Expected Results

      What do you expect to happen?

      Actual Results

      What do you observe is happening?

      Additional Notes

      Any additional information that may be useful to include.

      Attachments

        Activity

          People

            chris.kelly@mongodb.com Chris Kelly
            jibanjyoti442@gmail.com jibanjyoti dhal
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: