title: Node Js Mongoose how to make an update request
body: <p>I'm trying to make a put request in which I want to update my database, but I want to protect my old data. For example I have a database like this:</p>
  <pre><code>{
      &quot;_id&quot; : ObjectId(&quot;601068a96b6bdc1c40a9b67f&quot;),
      &quot;name&quot; : &quot;lamii boudamaa&quot;,
      &quot;email&quot; : &quot;dborhene6@gmail.com&quot;,
      &quot;msg&quot; : &quot;11&quot;,
      &quot;tel&quot; : &quot;2154549&quot;,
      &quot;__v&quot; : 0
  }
  </code></pre>
  <p>I have a parameter in my request like this</p>
  <pre><code>{
      &quot;entreprise&quot; : &quot;aa&quot;,
      &quot;poste&quot; : &quot;bb&quot;,
  }
  </code></pre>
  <p>I want to make a fusion with this to get something like this</p>
  <pre><code> {
          &quot;_id&quot; : ObjectId(&quot;601068a96b6bdc1c40a9b67f&quot;),
          &quot;name&quot; : &quot;lamii boudamaa&quot;,
          &quot;email&quot; : &quot;dborhene6@gmail.com&quot;,
          &quot;msg&quot; : &quot;11&quot;,
          &quot;tel&quot; : &quot;2154549&quot;,
          &quot;entreprise&quot; : &quot;aa&quot;,
          &quot;poste&quot; : &quot;bb&quot;,
          &quot;__v&quot; : 0
      }
  </code></pre>
  <p>I wrote this function:</p>
  <pre><code>router.put('/updateuser',async(req,res)=&gt;{
    var aa=(req.body);
    console.log(aa);
    console.log(req.query);
    console.log(req.query.name);
  
   User.findOneAndUpdate({'name': req.query.name }, { $set : {req.body} }).then(doc=&gt;{
    console.log('1');
    res.json('success');
    
  }).catch(err=&gt;console.log(err))
  
  
  });
  </code></pre>
  <p>but the problem I always get this</p>
  <pre><code>{
      &quot;_id&quot; : ObjectId(&quot;6017ede4959d6338a0a2e3c4&quot;),
      &quot;entreprise&quot; : &quot;&quot;,
      &quot;poste&quot; : &quot;&quot;,
      &quot;__v&quot; : 0
  }
  </code></pre>