You can add a new field to an existing MongoDB document using the $set operator. The $set operator replaces the value of a field with the specified value.
Here is an example using the mongo shell where we add a new field “email” to a document in “users” collection with a certain “\_id”:
```
db.users.updateOne(
{ _id: YOUR_DOCUMENT_ID },
{ $set: { “email” : “yourmail@mail.com” } }
)
```
If you’re using the MongoDB Node.js driver the syntax is similar:
```
const MongoClient = require(‘mongodb’).MongoClient;
const uri = ‘mongodb+srv://
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
client.connect((err, client) => { if (err) throw err;
const collection = client.db(“test”).collection(“users”); collection.updateOne( { _id: YOUR_DOCUMENT_ID }, { $set: { “email” : “yourmail@mail.com” } }, function(err, res) { if (err) throw err; console.log(“Document updated”); client.close(); }); }); ``` Note: Replace `