| @@ 89-102 (lines=14) @@ | ||
| 86 | * |
|
| 87 | * @return int The count of the documents updated. |
|
| 88 | */ |
|
| 89 | public function update($criteria, DocumentInterface $updated, $multiple = false) |
|
| 90 | { |
|
| 91 | $limit = $multiple ? 1 : null; |
|
| 92 | $documents = $this->onMatch($criteria, $limit); |
|
| 93 | ||
| 94 | $count = 0; |
|
| 95 | foreach ($documents as $document) { |
|
| 96 | $updated->setId($document->getId()); |
|
| 97 | $this->store->update($updated); |
|
| 98 | $count++; |
|
| 99 | } |
|
| 100 | ||
| 101 | return $count; |
|
| 102 | } |
|
| 103 | ||
| 104 | /** |
|
| 105 | * Remove documents from the collection. |
|
| @@ 112-125 (lines=14) @@ | ||
| 109 | * |
|
| 110 | * @return int The count of the document deleted. |
|
| 111 | */ |
|
| 112 | public function remove($criteria, $multiple = false) |
|
| 113 | { |
|
| 114 | $limit = $multiple ? 1 : null; |
|
| 115 | ||
| 116 | $documents = $this->onMatch($criteria, $limit); |
|
| 117 | ||
| 118 | $count = 0; |
|
| 119 | foreach ($documents as $document) { |
|
| 120 | $this->store->remove($document->get('_id')); |
|
| 121 | $count++; |
|
| 122 | } |
|
| 123 | ||
| 124 | return $count; |
|
| 125 | } |
|
| 126 | ||
| 127 | /** |
|
| 128 | * Find documents in the collection. |
|