Struct polodb_core::db::Collection[][src]

pub struct Collection<'a> { /* fields omitted */ }
Expand description

A wrapper of collection in struct.

All CURD methods can be done through this structure.

Find/Update/Delete operations need a query object.

Query operation:

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.

Logical operation:

NameDescription
$andJoins query clauses with a logical AND returns all documents that match the conditions of both clauses.
$orJoins query clauses with a logical OR returns all documents that match the conditions of either clause.

Example:

use std::rc::Rc;
use polodb_core::Database;
use polodb_bson::doc;

let mut db = Database::open_file("/tmp/test-collection").unwrap();
let mut collection = db.collection("test").unwrap();
collection.insert(doc! {
    "_id": 0,
    "name": "Vincent Chan",
    "score": 99.99,
}.as_mut());

Implementations

all the data in the collection return.

When query document is passed to the function. The result satisfies the query document.

Return the first element in the collection satisfies the query.

Return the size of all data in the collection.

When query is None, all the data in the collection will be updated. Basically the same as MongoDB.

Field Update Operators:
NameDescription
$incIncrements the value of the field by the specified amount.
$minOnly updates the field if the specified value is less than the existing field value.
$maxOnly updates the field if the specified value is greater than the existing field value.
$mulMultiplies the value of the field by the specified amount.
$renameRenames a field.
$setSets the value of a field in a document.
$unsetRemoves the specified field from a document.

Insert a document into the database. The returning boolean value represents if the DB inserted a “_id” for you.

When query is None, all the data in the collection will be deleted.

The size of data deleted returns.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.