docs
CURD
Delete

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

NameDescription
$eqMatches values that are equal to a specified value.
$gtMatches values that are greater than a specified value.
$gteMatches values that are greater than or equal to a specified value.
$inMatches any of the values specified in an array.
$ltMatches values that are less than a specified value.
$lteMatches values that are less than or equal to a specified value.
$neMatches all values that are not equal to a specified value.
$ninMatches none of the values specified in an array.
$regexMatches strings against the given regular expression.

These conditions are the same as those listed under Advanced conditions.