title: findOneAndUpdate not updating
body: <p>I am trying to update one of my documents stored in mongoose server by using <code>findOneAndUpdate</code>. I set it as a PUT request and this is how I defined it. </p>
  
  <pre><code>public updateConfigWithType(req: Request, res: Response) {
      configs.findOneAndUpdate({'companyInfo.uniquecompanyid': req.params.id}, { $set: { companyName: "ITSWORKING" }} ,(err,doc) =&gt; {
          if (err) {
              res.send(err);
          }else {
            res.json({
                message: 'Succesfully updated this item'
            });
          }
      })
  }
  </code></pre>
  
  <p>My PUT request URL is setup like this: <code>http://localhost:3000/parserConfig/123123wfdwedfwfwefwef</code></p>
  
  <p>This is a little piece of the the JSON data that exits in my documents in my mongoose server:</p>
  
  <pre><code>{
      "_id": {
          "$oid": "5bbf27ad4cf8a6be65ea6257"
      },
      "companyInfo": {
          "companyName": "example",
          "hashKey": "sdfsdf",
          "hashFunction": "sdfsdf",
          "uniquecompanyid": "123123wfdwedfwfwefwef"
      },
      "version": "1",
      "__v": 0,
      "parserConfig": {
          "id": {
              "fieldName": "key",
              "path": "key"
      },
  </code></pre>
  
  <p>So, I want to be able to find the right document by the uniquecompnayid that is in the URL and I specifically want to UPDATE the <code>parserConfig</code> field with what exists in <code>req.body</code>. I hardcoded everything for now for testing purposes.. Sending a PUT request currently gives me this answer in Postman:</p>
  
  <pre><code>{"message":"Succesfully updated this item"}
  </code></pre>
  
  <p>But nothing has been updated. What am I missing?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I changed the code for testing purposes... This is what i tried:</p>
  
  <pre><code>public updateConfigWithType(req: Request, res: Response) {
    var query = {'companyInfo.uniquecompanyid':req.params.id};
    configs.findOneAndUpdate(query, {$set:{'companyInfo.uniquecompanyid':"heheheheh"}}, {new:true}, function(err, doc){
        if (err) {
          return res.send(err);
        }
        return res.send(doc);
    });
  }
  </code></pre>
  
  <p>The response in postman is the OLD document. Nothing has been changed</p>
  
  <p><strong>UPDATE after spyros request</strong></p>
  
  <pre><code>10:26:34 PM web.1 |  Mongoose: configs.findOne({ 'companyInfo.uniquecompanyid': '123123wfdwedfwfwefwef' }, { new: true, projection: {} })
  10:26:34 PM web.1 |  PUT /parserConfig/123123wfdwedfwfwefwef 200 158.118 ms - 2089
  </code></pre>
  
  <p><strong>UPDATE new information notice</strong></p>
  
  <p>I came across this: <a href="https://github.com/Automattic/mongoose/issues/7011" rel="nofollow noreferrer">https://github.com/Automattic/mongoose/issues/7011</a></p>
  
  <p>where it says:</p>
  
  <p>I noticed that when calling findOneAndUpdate with an update doc property that isn't in the schema, the debug output shows the (wrong)? collection method.</p>
  
  <p>Why would it work to update the same property through Studio 3t but not through my code?</p>