How to update document with dynamic fields in node.js
<p>Assume that I have a document in database which has the following structure;</p>

<pre><code>id: 1,
name: alex,
age: 21
</code></pre>

<p>There are some updates in client side and the same document with <code>id:1</code> returns as;</p>

<pre><code>id: 1,
name: alex,
age: 21,
location: usa
</code></pre>

<p>where a new field <code>location</code> is added.</p>

<p>I want to update the document in database. I want to add this new inserted field but I couldn't find out how can I handle this situation. Because <code>location</code> is not static, it can be <code>surname</code>, <code>job</code> and so on. So new inserted fields are dynamic and I don't know in advance. </p>

<p>If the field <code>location</code> was static, I could write a query as;</p>

<pre><code>db.collection("user").updateOne( {id: 1},
                     {$set: {name: "alex", age: "21", location: "usa"}}, function(err, result){
     if(err){} 
     else{}
});
</code></pre>

<p>But now, how can I update the document with this newly added fields?</p>