CouchBackend
CouchDB backend.
Attributes
| Attribute | Type | Description |
|---|---|---|
| container | string = 'default' | The name of the CouchDB database used to store key-value pairs. |
| scheme | string = 'http' | The protocol used to connect to the CouchDB server, typically 'http' or 'https'. |
| host | string = 'localhost' | The hostname or IP address of the CouchDB server. |
| port | integer = 5984 | The port number on which the CouchDB server is listening. |
| username | string = null | The username for authenticating with the CouchDB server via basic authentication. |
| password | string = null | The password for authenticating with the CouchDB server via basic authentication. |
Constructor
Signature
def CouchBackend(
url: str = None,
*args: any,
**kwargs: any
)
Parameters
| Name | Type | Description |
|---|---|---|
| url | str = None | The URL containing CouchDB connection details. |
| *args | any | Variable length argument list passed to the parent class. |
| **kwargs | any | Arbitrary keyword arguments passed to the parent class. |
Methods
connection()
@classmethod
def connection() - > pycouchdb.Database
Provides a cached connection to the CouchDB database. This property initializes the connection on the first access.
Returns
| Type | Description |
|---|---|
pycouchdb.Database | The active CouchDB database connection |
get()
@classmethod
def get(
key: string
) - > any
Fetches the value associated with a specific key from the CouchDB database.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier for the document to retrieve |
Returns
| Type | Description |
|---|---|
any | The stored value if the key exists, otherwise None |
set()
@classmethod
def set(
key: string,
value: any
) - > null
Stores a value in the database under the specified key, performing an update if the document already exists.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier used to store the document |
| value | any | The data to be persisted in the database |
Returns
| Type | Description |
|---|---|
null | Nothing |
mget()
@classmethod
def mget(
keys: list
) - > list
Retrieves multiple values from the database for a given list of keys.
Parameters
| Name | Type | Description |
|---|---|---|
| keys | list | A collection of unique identifiers to fetch |
Returns
| Type | Description |
|---|---|
list | A list of values corresponding to the input keys in the same order |
delete()
@classmethod
def delete(
key: string
) - > null
Removes the document associated with the specified key from the CouchDB database.
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | The unique identifier of the document to be deleted |
Returns
| Type | Description |
|---|---|
null | Nothing |