$collectionHandler = new CollectionHandler($connection);
 $handler = new DocumentHandler($connection);
 // set up a document collection "users"
 $collection = new Collection("users");
 try {
     $collectionHandler->add($collection);
 } catch (\Exception $e) {
     // collection may already exist - ignore this error for now
 }
 // create a new document
 $user = new Document();
 $user->set("name", "John");
 $user->age = 19;
 $id = $handler->save("users", $user);
 // get documents by example
 $cursor = $collectionHandler->byExample("users", array("name" => "John", "age" => 19));
 var_dump($cursor->getAll());
 // get the ids of all documents in the collection
 $result = $handler->getAllIds("users");
 var_dump($result);
 // create another new document
 $user = new Document();
 $user->set("name", "j-lo");
 $user->level = 1;
 $user->vists = array(1, 2, 3);
 $id = $handler->save("users", $user);
 var_dump("CREATED A NEW DOCUMENT WITH ID: ", $id);
 // get this document from the server
 $userFromServer = $handler->getById("users", $id);
 var_dump($userFromServer);
 // update this document
 /**
  * Get document(s) by specifying an example
  *
  * This will throw if the list cannot be fetched from the server
  *
  *
  * @throws Exception
  *
  * @param mixed      $collectionId - collection id as string or number
  * @param mixed      $document     - the example document as a Document object or an array
  * @param bool|array $options      - optional, prior to v1.0.0 this was a boolean value for sanitize, since v1.0.0 it's an array of options.
  *                                 <p>Options are :<br>
  *                                 <li>'_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.</li>
  *                                 <li>'sanitize' - Deprecated, please use '_sanitize'.</li>
  *                                 <li>'_hiddenAttributes' - Set an array of hidden attributes for created documents.
  *                                 <li>'hiddenAttributes' - Deprecated, please use '_hiddenAttributes'.</li>
  *                                 <p>
  *                                 This is actually the same as setting hidden attributes using setHiddenAttributes() on a document. <br>
  *                                 The difference is, that if you're returning a resultset of documents, the getAll() is already called <br>
  *                                 and the hidden attributes would not be applied to the attributes.<br>
  *                                 </p>
  *                                 </li>
  *                                 <li>'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch</li>
  *                                 <li>'skip' -  Optional, The number of documents to skip in the query.</li>
  *                                 <li>'limit' -  Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.</li>
  *                                 </p>
  *
  * @return cursor - Returns a cursor containing the result
  *
  * @deprecated to be removed in version 2.0 - This function is being replaced by CollectionHandler::byExample()
  */
 public function getByExample($collectionId, $document, $options = false)
 {
     $collectionHandler = new CollectionHandler($this->getConnection());
     return $collectionHandler->byExample($collectionId, $document, $options);
 }