Sokil\Mongo\Collection::validate PHP Method

validate() public method

Validates a collection. The method scans a collection’s data structures for correctness and returns a single document that describes the relationship between the logical collection and the physical representation of the data.
public validate ( boolean $full = false ) : array
$full boolean Specify true to enable a full validation and to return full statistics. MongoDB disables full validation by default because it is a potentially resource-intensive operation.
return array
    public function validate($full = false)
    {
        $response = $this->getMongoCollection()->validate($full);
        if (!$response || $response['ok'] != 1) {
            throw new Exception($response['errmsg']);
        }
        return $response;
    }

Usage Example

Example #1
0
 public function testValidateOnExistedCollection()
 {
     $this->collection->createDocument(array('param' => 1))->save();
     $result = $this->collection->validate(true);
     $this->assertInternalType('array', $result);
 }