Mongotte

🗄 v1.0.0
⭐️ 0
Simple mongodb/mongodb integration into Nette Framework.
PHP 7.1
PHP 8.0

# Usage

For using this extension, we need Bytebase\Mongotte\Mongotte instance. It's created by Dependency Injection, so we can use it easily, for example like this:

/** @var Bytebase\Mongotte\Mongotte $mongotte */
private $mongotte;

public function __construct(Bytebase\Mongotte\Mongotte $mongotte)
{
    $this->mongotte = $mongotte;
}

# Database

Instance of Bytebase\Mongotte\Database we can get by two ways:

$database = $this->mongotte->getDatabase('exampleDatabase'); // via getDatabase method
$database = $this->mongotte->exampleDatabase; // via magic method

Then we can use every available methods in Database instance:

$database->aggregate(array $pipeline, array $options = []): \Traversable

$database->command($command, array $options = []): MongoDB\Driver\Cursor

$database->drop(array $options = []): array|object

$database->explain(Explainable $explainable, array $options = [])

$database->watch(array $pipeline, array $options = []): MongoDB\ChangeStream

$database->createCollection(string $collection, array $options = []): array|object

$database->dropCollection(string $collection, array $options = []): array|object

$database->listCollections(array $options = []): MongoDB\Model\CollectionInfoIterator

$database->modifyCollection(string $collection, array $collectionOptions, array $options): array|object

# Collection

Instance of Bytebase\Mongotte\Collection we can get by two ways:

$collection = $database->getCollection('exampleCollection'); // via getCollection method
$collection = $database->exampleCollection; // via magic method

Then we can use every available methods in Collection instance:

$collection->count($filter = [], array $options = []): int

$collection->countDocuments($filter, array $options = []): int

$collection->createIndexes(array $indexes, array $options = []): array

$collection->deleteMany($filter, array $options = []): MongoDB\DeleteResult

$collection->deleteOne($filter, array $options = []): MongoDB\DeleteResult

$collection->distinct(string $fieldName, $filter = [], array $options = [])

$collection->drop(array $options = []): array|object

$collection->dropIndex(string $indexName, array $options = []): array|object

$collection->dropIndexes(array $options = []): array|object

$collection->estimatedDocumentCount(array $options = []): int

$collection->find($filter, array $options = []): MongoDB\Driver\Cursor

$collection->findOne($filter, array $options = []): array|object|null

$collection->findOneAndDelete($filter, array $options = []): array|object|null

$collection->findOneAndReplace($filter, $replacement, array $options = []): array|object|null

$collection->insertMany(array $documents, array $options = []): MongoDB\InsertManyResult

$collection->insertOne($document, array $options = []): MongoDB\InsertOneResult

$collection->listIndexes(array $options = []): MongoDB\Model\IndexInfoIterator

$collection->replaceOne($filter, $replacement, array $options = []): MongoDB\UpdateResult

$collection->updateMany($filter, $update, array $options = []): MongoDB\UpdateResult

$collection->updateOne($filter, $update, array $options = []): MongoDB\UpdateResult

$collection->watch(array $pipeline, array $options = []): MongoDB\ChangeStream