Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #321 from doctrine/feature/mongodb-docs
Browse files Browse the repository at this point in the history
Starting docs for doctrine/mongodb.
  • Loading branch information
jwage authored Apr 2, 2018
2 parents 94844dc + c001586 commit 5cc080b
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Introduction
============

The Doctrine MongoDB project is an abstraction layer on top of MongoDB that the Doctrine MongoDB ODM project is built on top of.

.. note::

It wraps the legacy PHP driver and is in bug-fixes-only mode.

Connecting
----------

Creating new connections is easy using the ``Doctrine\MongoDB\Connection`` class:

.. code-block:: php
use Doctrine\MongoDB\Connection;
$connection = new Connection('mongodb://localhost');
Databases
---------

With the connection you can start selecting databases using the ``selectDatabase`` method:

.. code-block:: php
$database = $connection->selectDatabase('my_project_database');
Collections
-----------

Now you are ready to select a collection and insert some data using the ``insert`` method:

.. code-block:: php
$users = $database->selectCollection('users');
$user = [
'username' => 'jwage',
];
$users->insert($user);
Reading
-------

Reading data is easy using the ``find`` and ``findOne`` methods:

.. code-block:: php
$user = $users->findOne(['username' => 'jwage']);
Updating
--------

Updating a record is simple using the ``update`` method:

.. code-block:: php
$users->update(['username' => 'jwage'], ['$set' => ['isActive' => true]]);
Deleting
-------

Delete data from the collection using the ``remove`` method:

.. code-block:: php
$collection->remove(['username' => 'jwage']);

0 comments on commit 5cc080b

Please sign in to comment.