title: Delete object from mongoDB setting time after 30 days
body: <p>I'm using MongoDB, Nodejs, etc...</p>
  
  <p>I have an Activity collection about my user activities "Add new project", "Update project", "Delete project", etc, but I don't want that activity permanent on my database, I want that to expire in 30 days after created and added do user dashboard, but I don't now how to do...Hope you can help me!
  Thank you!</p>
  
  <p><strong>Here's my Activity Schema:</strong></p>
  
  <pre><code>let mongoose = require("mongoose");
  
  let activitySchema = new mongoose.Schema({
  
    activity: String,
    user: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User'
    },
    created: {
      type: Date,
      default: Date.now
    }
  })
  
  module.exports = mongoose.model('Activity', activitySchema);
  </code></pre>
  
  <p><strong>Here's my server side:</strong> </p>
  
  <p>(this is what send all user activity to dashboard)</p>
  
  <pre><code>//Render User Activity
  
  exports.render_user_activity = (req, res) =&gt; {
      let userid = req.user._id;
  
      User.findById(userid)
          .exec((err, user) =&gt; {
              if (err) {
                  console.log(err);
              }
  
              Activity.find({ user: user })
                  .exec((err, activities) =&gt; {
                      if (err) {
                          console.log(err);
                      }
                      res.send(activities);
              });
        });
  };
  </code></pre>
  
  <p>I've read that I can user .createIndex but I don't know how or if it's the best solution..
  Thank you!</p>