phpbotgram

MongoCollectionInterface

Minimal collection interface required by `MongoStorage`.

Defines only the four operations MongoStorage needs: findOne, updateOne, deleteOne, and findOneAndUpdate. By depending on this interface rather than the concrete \MongoDB\Collection, MongoStorage can be unit-tested with a lightweight anonymous-class mock without the ext-mongodb extension.

The real \MongoDB\Collection is not a subtype of this interface at the PHP type level (structural typing); a thin adapter is provided by MongoCollectionAdapter and wired up in MongoStorage::fromUrl() and MongoStorage::create().

Table of Contents

Methods

deleteOne()  : void
Delete a single document matching `$filter`.
findOne()  : null|object
Find a single document matching `$filter`.
findOneAndUpdate()  : null|object
Atomically find a document, apply `$update`, and return the result.
updateOne()  : void
Update a single document matching `$filter`.

Methods

deleteOne()

Delete a single document matching `$filter`.

public deleteOne(array<string, mixed> $filter[, array<string, mixed> $options = [] ]) : void
Parameters
$filter : array<string, mixed>

Query filter.

$options : array<string, mixed> = []

Command options.

findOne()

Find a single document matching `$filter`.

public findOne(array<string, mixed> $filter[, array<string, mixed> $options = [] ]) : null|object
Parameters
$filter : array<string, mixed>

Query filter.

$options : array<string, mixed> = []

Command options.

Return values
null|object

Matched document, or null when no document matches.

findOneAndUpdate()

Atomically find a document, apply `$update`, and return the result.

public findOneAndUpdate(array<string, mixed> $filter, array<string, mixed> $update[, array<string, mixed> $options = [] ]) : null|object

The return value after applying $update is returned (matching FindOneAndUpdate::RETURN_DOCUMENT_AFTER semantics used inside MongoStorage).

Parameters
$filter : array<string, mixed>

Query filter.

$update : array<string, mixed>

Update specification.

$options : array<string, mixed> = []

Command options.

Return values
null|object

Document after update, or null when no document matches.

updateOne()

Update a single document matching `$filter`.

public updateOne(array<string, mixed> $filter, array<string, mixed> $update[, array<string, mixed> $options = [] ]) : void
Parameters
$filter : array<string, mixed>

Query filter.

$update : array<string, mixed>

Update specification.

$options : array<string, mixed> = []

Command options (e.g. ['upsert' => true]).

On this page

Search results