lithium\data\source\MongoDb::describe PHP Method

describe() public method

Gets the column 'schema' for a given MongoDB collection. Only returns a schema if the 'schema' configuration flag has been set in the constructor.
See also: lithium\data\source\MongoDb::$_schema
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'));
    }

Usage Example

Example #1
0
 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());
 }