title: Mongoose: Don't push to array if document exists
body: <p>In the below code, I'm creating a checkin document which I then reference in the user document, on top with a car reference (in the user's collection). What I'm trying to achieve is to skip the insert to the array if the car already exists.</p>
  
  <p>How to check it? Or should I work with the model, and define a uniqueness reference in the <code>cars[]</code> array?</p>
  
  <pre><code>router.post('/', (req, res, err) =&gt; {
    var checkin = new Checkin(req.body);
  
    checkin._id = mongoose.Types.ObjectId();
  
    checkin.save()
      .then((checkinDoc) =&gt; {
        return User.findOneAndUpdate(
          { _id: ObjectID(checkin.user) },
          { $push: { checkins: checkinDoc._id, cars: checkin.car } },
          { new: true }
        )
      })
      .catch((err) =&gt; {
        res.send(err);
      });
  });
  </code></pre>
  
  <p>My <code>user.js</code> model</p>
  
  <pre><code>[...]
  
  cars: [{
      type: Schema.Types.ObjectId,
      ref: 'Car'
    }],
  
  [...]
  </code></pre>