delete() public method

Delete collection
public delete ( ) : Collection
return Collection
コード例 #1
0
ファイル: DocumentEventTest.php プロジェクト: sokil/php-mongo
 public function testCancelOperation_BeforeDelete()
 {
     $document = $this->collection->delete()->createDocument(array('field' => 'value'))->save()->onBeforeDelete(function (\Sokil\Mongo\Event $event, $eventName, $dispatcher) {
         $event->cancel();
     })->delete();
     $this->assertEquals(1, $this->collection->count());
 }
コード例 #2
0
ファイル: DocumentTest.php プロジェクト: Branik/php-mongo
 public function testPullFromThreeDimensionalUsingExpressionInValue()
 {
     $this->collection->delete();
     // create document
     $doc = $this->collection->createDocument(array('some' => array(array('sub' => array(array('a' => 1), array('b' => 2))), array('sub' => array(array('a' => 3), array('b' => 4))))));
     $doc->save();
     // push array to array
     $doc->pull('some', $this->collection->expression()->where('sub.a', 1));
     $doc->save();
     $this->assertEquals(array(array('sub' => array(array('a' => 3), array('b' => 4)))), $this->collection->getDocument($doc->getId())->some);
 }
コード例 #3
0
ファイル: CollectionTest.php プロジェクト: sokil/php-mongo
 public function testCappedCollectionInsert()
 {
     $this->collection = $this->database->createCappedCollection('capped_collection', 3, 30);
     $this->collection->createDocument(array('param' => 1))->save();
     $this->collection->createDocument(array('param' => 2))->save();
     $this->collection->createDocument(array('param' => 3))->save();
     $this->collection->createDocument(array('param' => 4))->save();
     $this->assertEquals(3, $this->collection->find()->count());
     $documents = $this->collection->find();
     $this->assertEquals(2, $documents->current()->param);
     $documents->next();
     $this->assertEquals(3, $documents->current()->param);
     $documents->next();
     $this->assertEquals(4, $documents->current()->param);
     $this->collection->delete();
 }
コード例 #4
0
ファイル: BatchTest.php プロジェクト: agolomazov/php-mongo
 public function tearDown()
 {
     if ($this->collection) {
         $this->collection->delete();
     }
 }
コード例 #5
0
ファイル: Queue.php プロジェクト: sokil/php-mongo
 /**
  * Clear queue
  * 
  * @return \Sokil\Mongo\Queue
  */
 public function clear()
 {
     $this->collection->delete();
     return $this;
 }