If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.

Use replaceOne instead of updateOne


You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Bulk upsert
    via by Vivek YS,
  • Best way to create bulk upsert
    via by miki haiat,
    • java.lang.IllegalArgumentException: Update document keys must start with $: _id at com.mongodb.DBCollectionImpl$Run.executeUpdates( at com.mongodb.DBCollectionImpl$Run.execute( at com.mongodb.DBCollectionImpl.executeBulkWriteOperation( at com.mongodb.DBCollection.executeBulkWriteOperation( at com.mongodb.DBCollection.executeBulkWriteOperation( at com.mongodb.BulkWriteOperation.execute( at com.mongodb.casbah.BulkWriteOperation$$anonfun$1.apply(BulkWriteOperation.scala:71) at com.mongodb.casbah.BulkWriteOperation$$anonfun$1.apply(BulkWriteOperation.scala:71) at scala.util.Try$.apply(Try.scala:161) at com.mongodb.casbah.BulkWriteOperation.execute(BulkWriteOperation.scala:71)
    No Bugmate found.