Skip to content

struct

Command

pub struct Command {
    pub action: Action,
    pub collection: String,
    pub filter: Value,
    pub sort: Value,
    pub projection: Value,
    pub limit: Option<i64>,
    pub skip: Option<u64>,
    pub document: Value,
    pub pipeline: Value,
}

One database operation, as JSON (filters in MongoDB Extended JSON, so {"_id": {"$oid": "…"}} matches an ObjectId).

Fields

action

pub action: Action

What the command does.

collection

pub collection: String

The collection it acts on.

filter

pub filter: Value

Which documents it matches, as a MongoDB query.

sort

pub sort: Value

How to order results: {"field": 1} ascending, -1 descending.

projection

pub projection: Value

Which fields to return: {"field": 1}.

limit

pub limit: Option<i64>

The most documents to return.

skip

pub skip: Option<u64>

How many matching documents to skip first.

document

pub document: Value

The document to insert, or the update ({"$set": …}).

pipeline

pub pipeline: Value

The stages of an aggregation.

Methods

check

pub fn check(self, policy: &Policy) -> Result<Command, String>

Validate against policy: an allowed collection and access, no server-side JavaScript ($where, $function, $accumulator), no writes to other collections from a pipeline ($out, $merge), and a capped limit. Returns the command with the limit applied.

Trait implementations