title: Mongoose Default Date
body: <p>Is there a specific setting you need to setup in order for mongoose to have this below Model working?</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-html lang-html prettyprint-override"><code>// The Model
  
  let theModelSchema = new Schema({
    created_on: {
      // type: Date, // Either Date or Number
      type: Number,
      default: Date.now(), // have also tried Date.now
    },
  })
  
  let TheModel = mongoose.model('TheModel', theModelSchema)
  
  // Save first entry
  
  let newEntry = new TheModel({
    value: 'randomValues here'
  })
  
  // The default date will be for example 123 here
  newEntry.save(function(err, savedNewEntry){
    console.log(savedNewEntry.created_on) // 123
  })
  
  // Save second entry a little bit later
  
  newEntry = new TheModel({
    value: 'randomValues here'
  })
  
  // The default date should be 125(or whatever)
  // But for some reason it stays as 123 and only updates // // when the server restats
  newEntry.save(function(err, savedNewEntry){
    console.log(savedNewEntry.created_on) // still 123, should be different
  })</code></pre>
  </div>
  </div>
  </p>
  
  <p>It works for me when I run it the first time, but it then saves another entry, it doesn't update the time in the new entry, it keeps the old time, as long as the same server instance is running.</p>
  
  <p>I have tried: 
  delete newEntry
  after the code runs</p>
  
  <p>So it seems that the server chaches the new Date and uses it on every entry
  The mongoose documentation tells me I am doing this right, as well as many other posts.
  <a href="http://mongoosejs.com/docs/defaults.html" rel="nofollow noreferrer">http://mongoosejs.com/docs/defaults.html</a></p>
  
  <p>So what am I doing wrong here?
  I of course know of many workarounds, but you want your model to have this automated.
  Help is greatly appreciated, thanks in advance!</p>