Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2670

UpdateOne $set won't accept string values with '$' in node.js

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.5.9
    • Component/s: None
    • Labels:
    • Environment:
      Ubuntu 18.04

      I'm trying to use bcrypt for passwords in Nodejs. Values I get are added to the DB correctly with the insertOne function for new collection entries. I can modify a field with the code below as long as the value for cryptPass doesn't have a $. So the commented string would be replaced correctly with the given code sample, while the one set in the example doesn't. Pass gets set to an empty value instead. The documentation doesn't say anything about alternative for setting values with $. If this is not a bug. Please provide details about how to proceed with $set string values that have $ in the documentation. I was looking around to see if there $ needs to be escaped, also didn't find anything.
       
      //let cryptPass = '2a12Ez4snVWhyWbM5ozNxSqvCONuELToqb6xxj5PYpZtap3zT5QQ8mya'
      let cryptPass = '$2a12Ez4snVWhyWbM5ozNxSqvCONuELToqb6xxj5PYpZtap3zT5QQ8mya'
       
      return db.collection(collectionName).updateOne(
      {_id: user._id},
      [{$set: {
      pass: cryptPass
      }}]
      )
       
       

            Assignee:
            thomas.reggi@mongodb.com Thomas Reggi (Inactive)
            Reporter:
            france.baril@architextus.com France Baril
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: