class MangoClient extends CouchDBClient (View source)

Constants

COLLATION_END

string \ufff0

Properties

protected $databaseName Name of the CouchDB database. from CouchDBClient
protected Client $httpClient The underlying HTTP Connection of the used DocumentManager. from CouchDBClient
protected string $version CouchDB Version. from CouchDBClient
static protected $clients from CouchDBClient

Methods

static CouchDBClient
create(array $options)

Factory method for CouchDBClients.

__construct(Client $client, string $databaseName)

No description

setHttpClient(Client $client)

No description

getHttpClient()

No description

getDatabase()

No description

array
getUuids(int $count = 1)

Let CouchDB generate an array of UUIDs.

findDocument(string $id)

Find a document by ID and return the HTTP response.

findRevisions(string $docId, mixed $revisions = null)

Find documents of all or the specified revisions.

findDocuments(array $ids, null $limit = null, null $offset = null)

Find many documents by passing their ids and return the HTTP response.

allDocs(int|null $limit = null, string|null $startKey = null, string|null $endKey = null, int|null $skip = null, bool $descending = false)

Get all documents.

string
getVersion()

Get the current version of CouchDB.

array
getAllDatabases()

Get all databases.

void
createDatabase(string $name)

Create a new database.

void
deleteDatabase(string $name)

Drop a database.

array
getDatabaseInfo(string $name = null)

Get Information about a database.

array
getChanges(array $params = [])

Get changes.

createBulkUpdater()

Create a bulk updater instance.

array
postDocument(array $data)

Execute a POST request against CouchDB inserting a new document, leaving the server to generate a uuid.

array
putDocument(array $data, string $id, string|null $rev = null)

Execute a PUT request against CouchDB inserting or updating a document.

void
deleteDocument(string $id, string $rev)

Delete a document.

createViewQuery(string $designDocName, string $viewName, DesignDocument $designDoc = null)

No description

createDesignDocument(string $designDocName, DesignDocument $designDoc)

Create or update a design document from the given in memory definition.

array
getCompactInfo()

GET /db/_compact.

array
compactDatabase()

POST /db/_compact.

array
compactView(string $designDoc)

POST /db/_compact/designDoc.

array
viewCleanup()

POST /db/_view_cleanup.

array
replicate(string $source, string $target, bool|null $cancel = null, bool|null $continuous = null, string|null $filter = null, array $ids = null, string|null $proxy = null)

POST /db/_replicate.

array
getActiveTasks()

GET /_active_tasks.

array
getRevisionDifference(array $data)

Get revision difference.

array|ErrorResponse|string
transferChangedDocuments(string $docId, array $missingRevs, CouchDBClient $target)

Transfer missing revisions to the target. The Content-Type of response from the source should be multipart/mixed.

resource
getChangesAsStream(array $params = [])

Get changes as a stream.

array
ensureFullCommit()

Commit any recent changes to the specified database to disk.

createMangoIndex(array $fields, string $ddoc = null, string $name = null)

Create a mango query index and return the HTTP response.

deleteMangoIndex(string $ddoc, string $name)

Delete a mango query index and return the HTTP response.

find(MangoQuery $query)

Find documents using Mango Query.

Details

static CouchDBClient create(array $options)

Factory method for CouchDBClients.

Parameters

array $options

Return Value

CouchDBClient

Exceptions

InvalidArgumentException

__construct(Client $client, string $databaseName)

Parameters

Client $client
string $databaseName

setHttpClient(Client $client)

Parameters

Client $client

Client getHttpClient()

Return Value

Client

getDatabase()

array getUuids(int $count = 1)

Let CouchDB generate an array of UUIDs.

Parameters

int $count

Return Value

array

Exceptions

CouchDBException

Response findDocument(string $id)

Find a document by ID and return the HTTP response.

Parameters

string $id

Return Value

Response

Response findRevisions(string $docId, mixed $revisions = null)

Find documents of all or the specified revisions.

If $revisions is an array containing the revisions to be fetched, only the documents of those revisions are fetched. Else document of all leaf revisions are fetched.

Parameters

string $docId
mixed $revisions

Return Value

Response

Response findDocuments(array $ids, null $limit = null, null $offset = null)

Find many documents by passing their ids and return the HTTP response.

Parameters

array $ids
null $limit
null $offset

Return Value

Response

Response allDocs(int|null $limit = null, string|null $startKey = null, string|null $endKey = null, int|null $skip = null, bool $descending = false)

Get all documents.

Parameters

int|null $limit
string|null $startKey
string|null $endKey
int|null $skip
bool $descending

Return Value

Response

string getVersion()

Get the current version of CouchDB.

Return Value

string

Exceptions

HTTPException

array getAllDatabases()

Get all databases.

Return Value

array

Exceptions

HTTPException

void createDatabase(string $name)

Create a new database.

Parameters

string $name

Return Value

void

Exceptions

HTTPException

void deleteDatabase(string $name)

Drop a database.

Parameters

string $name

Return Value

void

Exceptions

HTTPException

array getDatabaseInfo(string $name = null)

Get Information about a database.

Parameters

string $name

Return Value

array

Exceptions

HTTPException

array getChanges(array $params = [])

Get changes.

Parameters

array $params

Return Value

array

Exceptions

HTTPException

BulkUpdater createBulkUpdater()

Create a bulk updater instance.

Return Value

BulkUpdater

array postDocument(array $data)

Execute a POST request against CouchDB inserting a new document, leaving the server to generate a uuid.

Parameters

array $data

Return Value

array rev>

Exceptions

HTTPException

array putDocument(array $data, string $id, string|null $rev = null)

Execute a PUT request against CouchDB inserting or updating a document.

Parameters

array $data
string $id
string|null $rev

Return Value

array rev>

Exceptions

HTTPException

void deleteDocument(string $id, string $rev)

Delete a document.

Parameters

string $id
string $rev

Return Value

void

Exceptions

HTTPException

Query createViewQuery(string $designDocName, string $viewName, DesignDocument $designDoc = null)

Parameters

string $designDocName
string $viewName
DesignDocument $designDoc

Return Value

Query

Response createDesignDocument(string $designDocName, DesignDocument $designDoc)

Create or update a design document from the given in memory definition.

Parameters

string $designDocName
DesignDocument $designDoc

Return Value

Response

array getCompactInfo()

GET /db/_compact.

Return array of data about compaction status.

Return Value

array

Exceptions

HTTPException

array compactDatabase()

POST /db/_compact.

Return Value

array

Exceptions

HTTPException

array compactView(string $designDoc)

POST /db/_compact/designDoc.

Parameters

string $designDoc

Return Value

array

Exceptions

HTTPException

array viewCleanup()

POST /db/_view_cleanup.

Return Value

array

Exceptions

HTTPException

array replicate(string $source, string $target, bool|null $cancel = null, bool|null $continuous = null, string|null $filter = null, array $ids = null, string|null $proxy = null)

POST /db/_replicate.

Parameters

string $source
string $target
bool|null $cancel
bool|null $continuous
string|null $filter
array $ids
string|null $proxy

Return Value

array

Exceptions

HTTPException

array getActiveTasks()

GET /_active_tasks.

Return Value

array

Exceptions

HTTPException

array getRevisionDifference(array $data)

Get revision difference.

Parameters

array $data

Return Value

array

Exceptions

HTTPException

array|ErrorResponse|string transferChangedDocuments(string $docId, array $missingRevs, CouchDBClient $target)

Transfer missing revisions to the target. The Content-Type of response from the source should be multipart/mixed.

Parameters

string $docId
array $missingRevs
CouchDBClient $target

Return Value

array|ErrorResponse|string

Exceptions

HTTPException

resource getChangesAsStream(array $params = [])

Get changes as a stream.

This method similar to the getChanges() method. But instead of returning the set of changes, it returns the connection stream from which the response can be read line by line. This is useful when you want to continuously get changes as they occur. Filtered changes feed is not supported by this method.

Parameters

array $params

Return Value

resource

Exceptions

HTTPException

array ensureFullCommit()

Commit any recent changes to the specified database to disk.

Return Value

array

Exceptions

HTTPException

createMangoIndex(array $fields, string $ddoc = null, string $name = null)

Create a mango query index and return the HTTP response.

Parameters

array $fields
  • index fields
string $ddoc
  • design document name
string $name
  • view name

deleteMangoIndex(string $ddoc, string $name)

Delete a mango query index and return the HTTP response.

Parameters

string $ddoc
  • design document name
string $name
  • view name

Response find(MangoQuery $query)

Find documents using Mango Query.

Parameters

MangoQuery $query

Return Value

Response