public describe ( mixed $collection, mixed $fields = [], array $meta = [] ) : array | ||
$collection | mixed | Specifies a collection name for which the schema should be queried. |
$fields | mixed | Any schema data pre-defined by the model. |
$meta | array | Any meta information pre-defined in the model. |
return | array | Returns an associative array describing the given collection's schema. |
public function describe($collection, $fields = array(), array $meta = array())
{
if (!$fields && ($func = $this->_schema)) {
$fields = $func($this, $collection, $meta);
}
return $this->_instance('schema', compact('fields'));
}
public function testSchemaCallback() { $schema = array('_id' => array('type' => 'id'), 'created' => array('type' => 'date')); $db = new MongoDb(array('autoConnect' => false, 'schema' => function () use($schema) { return $schema; })); $this->assertEqual($schema, $db->describe(null)->fields()); }