lithium\data\source\http\adapter\CouchDb::describe()
Implements
lithium\data\Source::describe()
Describe database, create if it does not exist.
Parameters
-
string
$entity
-
array
$schema
Any schema data pre-defined by the model.
-
array
$meta
Returns
lithium\data\SchemaSource
public function describe($entity, $schema = array(), array $meta = array()) {
$database = $this->_config['database'];
if (!$this->_db) {
$result = $this->get($database);
if (isset($result->db_name)) {
$this->_db = true;
}
if (!$this->_db) {
if (isset($result->error)) {
if ($result->error === 'not_found') {
$result = $this->put($database);
}
}
if (isset($result->ok) || isset($result->db_name)) {
$this->_db = true;
}
}
}
if (!$this->_db) {
throw new ConfigException("Database `{$entity}` is not available.");
}
return $this->_instance('schema', array(array('fields' => $schema)));
}