title: ReferenceError saving data to mongodb using mongoose in node.js
body: <p>I'm trying to save to a user collection in mongodb using mongoose and I'm getting the following </p>
  
  <p><strong>Error:</strong>        <code>ReferenceError: Cannot access 'user' before initialization</code>.</p>
  
  <pre><code>const user = mongoose.model("users");
  
  try {
          const user = await new user({
            googleId: profile.id,
            name: profile.displayName,
            email: profile.emails[0].values
          }).save();
  
          done(null, user);
        } catch (err) {
          console.log("error " + err);
        }
      }  
  </code></pre>
  
  <p>Here is my user.js file:   </p>
  
  <pre><code> const mongoose = require("mongoose");
   const { Schema } = mongoose;
  
   const userSchema = new Schema({
       googleId: String,
       name: String,
       email: String
   });
  
   mongoose.model("users", userSchema);
  </code></pre>