mongodb / mongo-rust-driver

The official MongoDB Rust Driver
https://www.mongodb.com/docs/drivers/rust/current/
Apache License 2.0
1.44k stars 164 forks source link

How to perform the upsert operation? Other languages support this parameter, but the new 3.0 version does not see the parameter for this option #1196

Closed tianshangwuyun closed 2 months ago

tianshangwuyun commented 2 months ago

Versions/Environment

  1. What version of Rust are you using?
  2. What operating system are you using?
  3. What versions of the driver and its dependencies are you using? (Run cargo pkgid mongodb & cargo pkgid bson)
  4. What version of MongoDB are you using? (Check with the MongoDB shell using db.version())
  5. What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?

Describe the bug

A clear and concise description of what the bug is.

BE SPECIFIC:



**To Reproduce**
Steps to reproduce the behavior:
1. First, do this.
2. Then do this.
3. After doing that, do this.
4. And then, finally, do this.
5. Bug occurs.
abr-egn commented 2 months ago

An upsert can be performed by using the upsert setter on any of the relevant actions:

let result = collection.update_one(query, update).upsert(true).await?;