title: Nextjs connect with MongoDB
body: <p>I'm new in nextjs and coding, I try in node.js is fine, but I try in next.js, I get this error, help!</p>
  <p>Thank You,</p>
  <p><strong>OverwriteModelError: Cannot overwrite 'CountDown' model once compiled.</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import mongoose from 'mongoose'
  
  // mongoose connection
  mongoose.connect(process.env.MONGODB_URI);
  
  // mongoose items setup -------------------------
  const countdownSchema = {
      title: {
          type: String,
          required: [true, 'Please input Event name'],
          unique: true,
          trim: true,
          maxLength: [50, 'Title cannot be more then 50 charactor']
      },
      year: String,
      month: String,
      day: String,
      time: String
  };
  // mongoose model
  const CountDown = mongoose.model("CountDown", countdownSchema);
  // end mongoose setup ----------------------------
  
  export default function Model() {
  
      // default build mongoDB
      const item = new CountDown({
      title: '2023 Chinese New Year',
      year: '2023',
      month: 'January',
      day: '22',
      time: '09:00'
      });
  
      item.save();
  
      return (
          &lt;&gt;
              &lt;h1&gt;Hello World&lt;/h1&gt;
          &lt;/&gt;
      )
  }</code></pre>
  </div>
  </div>
  </p>