title: Trying to update data to compass using mongoose but it shows error
body: <p>I am a newbie and learning mongoose. I am trying to connect with local server and update data to mongoDB Compass but its' throwing error. I am not able to understand what mistake I am doing. Kindly help me to solve it.</p>
  <pre><code>db.on(&quot;connection&quot;, () =&gt; console.log(&quot;Connected Successfully&quot;));
  db.on(&quot;disconnect&quot;, () =&gt; console.log(&quot;Disconnected Successfully&quot;));
  db.on(&quot;error&quot;, console.error.bind(console, &quot;connection error:&quot;));
  db.once(&quot;open&quot;, function () {
  firstEmployee.save(function (err, res) {
  if (err) throw error;
  console.log(res);
  });
  db.close();
  });
  </code></pre>
  <p>and error is = throw er; // Unhandled 'error' event
  ^</p>
  <p>ReferenceError: error is not defined</p>