Skip to main content

CouchBackend

CouchDB backend.

Attributes

AttributeTypeDescription
containerstring = 'default'The name of the CouchDB database used to store key-value pairs.
schemestring = 'http'The protocol used to connect to the CouchDB server, typically 'http' or 'https'.
hoststring = 'localhost'The hostname or IP address of the CouchDB server.
portinteger = 5984The port number on which the CouchDB server is listening.
usernamestring = nullThe username for authenticating with the CouchDB server via basic authentication.
passwordstring = nullThe password for authenticating with the CouchDB server via basic authentication.

Constructor

Signature

def CouchBackend(
url: str = None,
*args: any,
**kwargs: any
)

Parameters

NameTypeDescription
urlstr = NoneThe URL containing CouchDB connection details.
*argsanyVariable length argument list passed to the parent class.
**kwargsanyArbitrary 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

TypeDescription
pycouchdb.DatabaseThe active CouchDB database connection

get()

@classmethod
def get(
key: string
) - > any

Fetches the value associated with a specific key from the CouchDB database.

Parameters

NameTypeDescription
keystringThe unique identifier for the document to retrieve

Returns

TypeDescription
anyThe 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

NameTypeDescription
keystringThe unique identifier used to store the document
valueanyThe data to be persisted in the database

Returns

TypeDescription
nullNothing

mget()

@classmethod
def mget(
keys: list
) - > list

Retrieves multiple values from the database for a given list of keys.

Parameters

NameTypeDescription
keyslistA collection of unique identifiers to fetch

Returns

TypeDescription
listA 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

NameTypeDescription
keystringThe unique identifier of the document to be deleted

Returns

TypeDescription
nullNothing