lithium\data\source\http\adapter\CouchDb::describe()

public method

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\Schema

Source

	public function describe($entity, $schema = [], array $meta = []) {
		$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 Libraries::instance(null, 'schema', [['fields' => $schema]], $this->_classes);
	}