title: How to update and upsert multiple documents in MongoDB in django
body: <p>I want to upsert multiple documents with a single query in mongodb like we can do in mysql with duplicate key update.</p>
  
  <p>I have already tried the solution for upserting each doc through iteration via</p>
  
  <pre><code>db.collection.update_one({'hotel_id': hotel_doc['hotel_id']},
                                 {'$set': {**hotel_doc, **{'ut': ct}}, '$setOnInsert': {'ct': ct}}, upsert=True)
  </code></pre>
  
  <p>Please help</p>
  
  <p>my collection looks like this</p>
  
  <pre><code>{
    "_id": ObjectId("5eea01d030b03c07d0352ac9"),
    "hotel_id": "200701181651218971",
    "hotel_status": true,
    "country_id": "IN",
    "city_id": "XCR",
    "star_rating": "5",
    "chain_code": "TJ",
    "property_type": "CHAIN",
    "location": {
      "n": "Coorg",
      "crds": {
        "type": "Point",
        "coordinates": [
          75.6589525123024,
          12.3781178180329
        ]
      }
    }
  }
  </code></pre>