Golang-Migrate not able to recognize dollar symbol db.runCommand

Viewed 90

While running db.runCommand it is not able to recognize dollar symbol and therefore treating $answer as string and not actual value.

[
  {
    "update": "userfeedback",
    "updates": [
      {
        "q": {
          "userId": 8426,
         "questionIdentifier": "resumeLink"
        },
        "u": {
          "$set": {
            "answer": [
              {
              "resumeLink": "$answer",
              "resumeId": "$UUID().hex().match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/).slice(1,6).join('-')",
              "uploadSizeInByte": -1,
              "source":"manual",
              "dateUploaded": "$updatedAt"
              }
            ]
          }
        }
      }
    ]
  }
]

Output: dollar symbol is not recognized.

 [ 
        {
            "resumeLink" : "$answer",
            "resumeId" : "$UUID().hex().match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/).slice(1,6).join('-')",
            "uploadSizeInByte" : -1,
            "source" : "manual",
            "dateUploaded" : "$updatedAt"
        }
    ]

While using updateMany query the similar query works Update Query:

db.getCollection('userfeedback').updateMany(
    {userId:8426, questionIdentifier:"resumeLink"},
    [{
        "$set": {
                    answer: [{  
                              "resumeLink": "$answer",
                              "resumeId": UUID().hex().match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/).slice(1,6).join('-'),
                              "uploadSizeInByte": -1,
                              "source":"manual",
                              "dateUploaded": "$updatedAt"
                              }]
            }
    }]
)

Result:

 [
                {
                    "resumeLink": "https://cdn.upgrad.com/resume/asasjyotiranjana11.docx",
                    "dateUploaded": "2051-04-26T14:30:00.000Z",
                    "uploadSizeInByte": 644234,
                    "resumeId": "7fa1478d-478f-4869-9c4b-7ca8c0b9434g",
                    "source": "hiration"
                }
]

can some one help me how to get same result with runCommand. thanks in advance

0 Answers
Related