šŸ’
Cherry3
Support
  • 🄳Welcome
    • šŸ“•Change Log
  • šŸŽ—ļøModel & Schema
    • 🪔Usage & Options
  • šŸ’Operators
    • 🧵find()
    • 🧵allRows()
    • 🧵findOne()
    • 🧵findOneAndUpdate()
    • 🧵findOneAndDelete()
    • 🧵findById()
    • 🧵findByIdAndUpdate()
    • 🧵findByIdAndDelete()
    • 🧵insertOne()
    • 🧵insertMany()
    • 🧵updateOne()
    • 🧵updateMany()
    • 🧵deleteOne()
    • 🧵deleteMany()
    • 🧵create() & save()
    • 🧵schemaInfo()
    • 🧵dropCollection()
    • 🧵renameCollection()
    • 🧵renameColumn()
    • 🧵deleteColumn()
    • 🧵distinct()
    • 🧵countDocuments()
    • 🧵inspect()
    • 🧵aggregate()
  • šŸ”§Other Operators
    • šŸ†™Update Operators
      • ⚔$set
      • ⚔$unset
      • ⚔$inc
      • ⚔$dec
      • ⚔$push
      • ⚔$pull
      • ⚔$pop
    • šŸ“”Filter & Process Operators
      • ⚔$limit
      • ⚔$skip
      • ⚔$sort
      • ⚔$upsert
      • ⚔$multiPull
  • šŸŖSQL Config File
Powered by GitBook
On this page

Was this helpful?

  1. Other Operators
  2. Filter & Process Operators

$upsert

Name
Usage Type
Description

$upsert

Boolean

$upsert Operator Will Create Operators Like FindOneAndUpdate If The Entered Data Doesn't Exist

/* Example Usage */
const model = ...Someone Model

(async () => {

await model.findOneAndUpdate({ classNumber: 999 },{ $set:{ name: "Five", surname: "So Beş" } },{ $upsert: true });
/*
{id:3, name: 'Five', surname: 'So Beş', age: null, classNumber: 999, achievements:[]},
*/

})();
Previous$sortNext$multiPull

Last updated 1 year ago

Was this helpful?

šŸ”§
šŸ“”
⚔