delete() public method

Delete collection
public delete ( ) : Collection
return Collection
Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 public function tearDown()
 {
     if ($this->collection) {
         $this->collection->delete();
     }
 }
Exemplo n.º 5
0
 /**
  * Clear queue
  * 
  * @return \Sokil\Mongo\Queue
  */
 public function clear()
 {
     $this->collection->delete();
     return $this;
 }