Delete
Use delete_one to delete at most one matching document, or delete_many to
delete every matching document. Both methods return a DeleteResult; its
deleted_count field reports how many documents were removed.
use polodb_core::bson::{doc, Document};
use polodb_core::{CollectionT, Database};
fn main() -> polodb_core::Result<()> {
let db = Database::open_path("./polodb-data")?;
let collection = db.collection::<Document>("books");
let result = collection.delete_many(doc! {
"author": "George Orwell",
})?;
println!("deleted: {}", result.deleted_count);
Ok(())
}Condition
| Name | Description |
|---|---|
| $eq | Matches values that are equal to a specified value. |
| $gt | Matches values that are greater than a specified value. |
| $gte | Matches values that are greater than or equal to a specified value. |
| $in | Matches any of the values specified in an array. |
| $lt | Matches values that are less than a specified value. |
| $lte | Matches values that are less than or equal to a specified value. |
| $ne | Matches all values that are not equal to a specified value. |
| $nin | Matches none of the values specified in an array. |
| $regex | Matches strings against the given regular expression. |
These conditions are the same as those listed under Advanced conditions.