Answers for "mongoose unique subdocument"

0

mongoose unique subdocument

Model.update({
  _id: '576328595b2880f831413b92',
  'subdocs.name': {
    $ne: 'Unique Name'
  }
}, {
  $push: {
    subdocs: {
      name: 'Unique Name'
    }
  }
}).then((raw) => {
  // check raw.nModified value
}).catch(next);
Posted by: Guest on March-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language