title: How to use mongoose to make changes in two different collections in one nodejs query
body: <p>In this application, I am trying to update a field value, if it is successful then I want to save into a log collection, however, not all the data are saved in the log collection, I am not sure if I am doing it the right way, would appreciate if someone could help out.</p>
  
  <p>here is the query :</p>
  
  <pre><code>// both models(Log &amp; Inventory are imported)
  
  router.get("/add_product/:id/:num/:quantity/:order", (req, res) =&gt; {
    var id = req.params.id;
    var quantity = req.params.quantity;
    var order = req.params.order;
    // console.log('id----', id);
    var num_mod = req.params.num;
    var modified_count = parseInt(num_mod) - parseInt(quantity);
    console.log("num_mod----", num_mod);
    Inventory.findByIdAndUpdate(id, { quantity: parseInt(num_mod) }, { new: true }, function(
      err,
      inventory
    ) {
      if (err) {
        console.log("err", err);
        res.status(500).send(err);
      } else {
        console.log(inventory.name);
  
        const newLog = new Log({
          name: inventory.name,
          description: inventory.description,
          price: parseInt(inventory.price),
          quantity: parseInt(inventory.quantity),
          modified_quantity: parseInt(modified_count),
          itemDest: order //this is not being saved
        });
        newLog.save(function(err, Log) {
          if (err) {
            console.log(err);
          } else {
            console.log("add log success");
            res.send(inventory);
          }
        });
      }
    });
  });
  </code></pre>
  
  <p>URL from front end :</p>
  
  <pre><code>// order is a string
  </code></pre>
  
  <p>here is the Log schema :</p>
  
  <pre class="lang-js prettyprint-override"><code>const mongoose = require("mongoose");
  
  const LogSchema = new mongoose.Schema(
    {
      // _id: mongoose.Schema.Types.ObjectId,
      name: { type: String, required: true },
      description: { type: String, required: true },
      price: { type: Number, required: true },
      quantity: { type: Number, required: true },
      modified_quantity: { type: Number, required: true },
      supplier: String,
      taxable: Boolean,
      itemDest: String
    },
    { timestamps: true }
  );
  
  // Create model from the schema
  const Log = mongoose.model("Log", LogSchema);
  
  // Export model
  module.exports = Log;
  </code></pre>
  
  <p>and here is the inventory schema</p>
  
  <pre class="lang-js prettyprint-override"><code>const mongoose = require("mongoose");
  
  //create Schema
  const InventorySchema = new mongoose.Schema(
    {
      // _id: mongoose.Schema.Types.ObjectId,
      name: { type: String, required: true },
      description: { type: String, required: true },
      price: { type: Number, required: true },
      quantity: { type: Number, required: true },
      supplier: String,
      taxable: Boolean
    },
    { timestamps: true }
  );
  
  // Create model from the schema
  const Inventory = mongoose.model("Inventory", InventorySchema);
  
  // Export model
  module.exports = Inventory;
  </code></pre>
  
  <p>My issue is with this line <code>"itemDest: order"</code> in the query, I intend to save the value of <code>"order"</code> extracted from <code>"req.params.order"</code> into <code>"itemDest"</code> but it doesn't save.</p>