mongo-rust-driver icon indicating copy to clipboard operation
mongo-rust-driver copied to clipboard

call update_many only update one record?

Open adminSxs opened this issue 2 years ago • 2 comments


     for id in ids {
        doc_ids.push((
            "_id".to_string(),
            Bson::ObjectId(oid::ObjectId::parse_str(id).unwrap()),
        ));
    }
     let db = client.database("account");
    let collections = db.collection::<Value>(collect);
    let filter = Document::from_iter(doc_ids.clone());
    let result=  collections.update_many(filter.clone(), doc! {"$set":{"to_ack":to_ack}}, None)
                .await
                .unwrap();

only last record updated!

adminSxs avatar Jul 31 '22 15:07 adminSxs

Hi @adminSxs, thank you for filing this issue! It looks like you're trying to query all documents with _id values contained in the doc_ids array; you may want to use the $in query operator for this purpose. For further questions about using the update operation I'd recommend posting on the MongoDB Community Forum. Feel free to let me know if you have any questions about using the Rust driver!

isabelatkinson avatar Aug 03 '22 17:08 isabelatkinson

There has not been any recent activity on this ticket, so we are marking it as stale. If we do not hear anything further from you, this issue will be automatically closed in one week.

github-actions[bot] avatar Aug 17 '22 02:08 github-actions[bot]

There has not been any recent activity on this ticket, so we are closing it. Thanks for reaching out and please feel free to file a new issue if you have further questions.

github-actions[bot] avatar Aug 25 '22 02:08 github-actions[bot]