Skip to content

monkey.dao.results

Encapsulates results of various database operations including delete, update, insert, and replace.

The module defines specialized classes for operation results, providing detailed insights into the execution of common database actions. Each class represents a specific type of database action and provides structured access to the results, including the count of records affected and any associated raw data.

Classes:

monkey.dao.results.DeleteResult

DeleteResult(
    rec_count: int,
    affected_keys: Optional[List[Any]] = None,
    raw_result: Optional[Any] = None,
)

Bases: OperationResult

Represents the outcome of a delete operation.

Initializes an instance of the class with details regarding a delete operation.

Parameters:

  • rec_count (int) –

    The number of records affected by the operation.

  • affected_keys (Optional[List[Any]], default: None ) –

    The list of keys associated with the deleted records. Use an empty list if no new record was deleted. Use None if not supported by the implementation. Default: None.

  • raw_result (Optional[Any], default: None ) –

    The raw data resulting from the operation execution for further processing or storage. Defaults to None.

Attributes:

monkey.dao.results.DeleteResult.affected_keys instance-attribute

affected_keys = affected_keys

monkey.dao.results.DeleteResult.deleted_count property

deleted_count: int

This property provides access to the count of records that have been marked or processed as deleted. It is expected to return the current count of such records, which is represented internally by a tracked attribute.

Returns:

  • int

    The number of records that have been marked as deleted.

monkey.dao.results.DeleteResult.deleted_keys property

deleted_keys: List[Any]

Retrieves the list of deleted keys if available.

Returns:

  • List[Any]

    The list of affected (deleted) keys.

Raises:

  • UnsupportedFeatureError

    If the object does not support handling deleted keys.

monkey.dao.results.DeleteResult.op_type instance-attribute

op_type = op_type

monkey.dao.results.DeleteResult.raw_result instance-attribute

raw_result = raw_result

monkey.dao.results.DeleteResult.rec_count instance-attribute

rec_count = rec_count

monkey.dao.results.InsertResult

InsertResult(
    rec_count: int,
    affected_keys: Optional[List[Any]],
    raw_result: Optional[Any] = None,
)

Bases: OperationResult

Represents the result of an insert operation.

Initializes an instance of the class with details regarding an insert operation.

Parameters:

  • rec_count (int) –

    The number of records affected by the operation.

  • affected_keys (Optional[List[Any]]) –

    The list of keys associated with the inserted records. Use an empty list if no new record was inserted. Use None if not supported by the implementation. Default: None.

  • raw_result (Optional[Any], default: None ) –

    Raw data or result object associated with the operation.

Attributes:

monkey.dao.results.InsertResult.affected_keys instance-attribute

affected_keys = affected_keys

monkey.dao.results.InsertResult.inserted_count property

inserted_count: int

Provides access to the number of records inserted into the database or a relevant storage.

Returns:

  • int

    The count of records inserted so far.

monkey.dao.results.InsertResult.inserted_keys property

inserted_keys: List[Any]

Provides access to the list of keys that have been affected.

Returns:

  • List[Any]

    The list of affected keys.

Raises:

  • UnsupportedFeatureError

    If the feature is not supported.

monkey.dao.results.InsertResult.op_type instance-attribute

op_type = op_type

monkey.dao.results.InsertResult.raw_result instance-attribute

raw_result = raw_result

monkey.dao.results.InsertResult.rec_count instance-attribute

rec_count = rec_count

monkey.dao.results.OperationResult

OperationResult(
    op_type: OperationType,
    rec_count: int = 0,
    affected_keys: Optional[List[Any]] = None,
    raw_result: Optional[Any] = None,
)

Bases: ABC

Represents the result of an operation.

This class contains details of the operation result, including the type of operation, the number of records involved, and the raw result.

Attributes:

  • op_type

    The type of the operation.

  • rec_count

    The number of records affected by the operation.

  • affected_keys

    The list of record keys affected by the operation.

  • raw_result

    The raw result of the operation. It depends on the data source and the operation type.

Initializes the instance. Used for creating an object encapsulating the result details of a specific operation.

Parameters:

  • op_type (OperationType) –

    The specific operation type being performed.

  • rec_count (int, default: 0 ) –

    The count of records affected by the operation.

  • affected_keys (Optional[List[Any]], default: None ) –

    The list of record keys affected by the operation. Use an empty list if no record was affected. Use None if not supported by the implementation. Default: None.

  • raw_result (Optional[Any], default: None ) –

    The raw result data or object returned from the operation.

monkey.dao.results.OperationResult.affected_keys instance-attribute

affected_keys = affected_keys

monkey.dao.results.OperationResult.op_type instance-attribute

op_type = op_type

monkey.dao.results.OperationResult.raw_result instance-attribute

raw_result = raw_result

monkey.dao.results.OperationResult.rec_count instance-attribute

rec_count = rec_count

monkey.dao.results.ReplaceResult

ReplaceResult(
    rec_count: int,
    affected_keys: Optional[List[Any]] = None,
    raw_result: Optional[Any] = None,
    did_upsert: bool = False,
)

Bases: OperationResult

Represents the result of a replace operation.

This class extends OperationResult and is specifically designed to handle the results of a document replace operation. It includes functionality to track whether records were upserted as part of the replacement action.

Attributes:

  • did_upsert

    Indicates if an upsert operation occurred during the replacement process.

Initializes an instance of the class with details regarding a replace operation.

Parameters:

  • rec_count (int) –

    The number of records affected by the replace operation.

  • affected_keys (Optional[List[Any]], default: None ) –

    The list of keys associated with the affected records. Use an empty list if no new record was updated. Use None if not supported by the implementation. Default: None.

  • raw_result (Optional[Any], default: None ) –

    Raw result object containing the replace operation's detailed outcome.

  • did_upsert (bool, default: False ) –

    Indicates whether the replace operation resulted in an upsert (insert if no record exists). Default is False.

monkey.dao.results.ReplaceResult.affected_keys instance-attribute

affected_keys = affected_keys

monkey.dao.results.ReplaceResult.did_upsert instance-attribute

did_upsert = did_upsert

monkey.dao.results.ReplaceResult.op_type instance-attribute

op_type = op_type

monkey.dao.results.ReplaceResult.raw_result instance-attribute

raw_result = raw_result

monkey.dao.results.ReplaceResult.rec_count instance-attribute

rec_count = rec_count

monkey.dao.results.ReplaceResult.replaced_count property

replaced_count: int

Provides access to the count of records that have been replaced.

This count does not distinguish between records that have been modified and those that have been inserted in the event of an upsert.

Returns:

  • int

    The count of records replaced.

monkey.dao.results.ReplaceResult.replaced_keys property

replaced_keys: List[Any]

Retrieves the list of replaced record keys if available.

This list contains both the keys of modified records and those of inserted records, in the event of an upsert.

Returns:

  • List[Any]

    The list of affected (updated or inserted) keys.

Raises:

  • UnsupportedFeatureError

    If the object does not support handling updated keys.

monkey.dao.results.UpdateResult

UpdateResult(
    rec_count: int,
    affected_keys: Optional[List[Any]] = None,
    raw_result: Optional[Any] = None,
    did_upsert: bool = False,
)

Bases: OperationResult

Represents the result of an update operation.

Attributes:

  • did_upsert

    Indicates whether the operation resulted in an upsert (insert if not found).

Initializes an instance of the class with details regarding an update operation.

Parameters:

  • rec_count (int) –

    The number of records affected by the update operation.

  • affected_keys (Optional[List[Any]], default: None ) –

    The list of keys associated with the affected records. Use an empty list if no new record was updated. Use None if not supported by the implementation. Default: None.

  • raw_result (Optional[Any], default: None ) –

    The raw result returned from the database operation.

  • did_upsert (bool, default: False ) –

    Indicates if the operation resulted in an upsert to the database. Defaults to False.

monkey.dao.results.UpdateResult.affected_keys instance-attribute

affected_keys = affected_keys

monkey.dao.results.UpdateResult.did_upsert instance-attribute

did_upsert = did_upsert

monkey.dao.results.UpdateResult.op_type instance-attribute

op_type = op_type

monkey.dao.results.UpdateResult.raw_result instance-attribute

raw_result = raw_result

monkey.dao.results.UpdateResult.rec_count instance-attribute

rec_count = rec_count

monkey.dao.results.UpdateResult.updated_count property

updated_count: int

Provides the number of records that have been updated.

This count does not distinguish between records that have been updated and those that have been inserted in the event of an upsert.

Returns:

  • int

    The count of updated records.

monkey.dao.results.UpdateResult.updated_keys property

updated_keys: List[Any]

Retrieves the list of deleted keys if available.

This list contains both the keys of modified records and those of inserted records, in the event of an upsert.

Returns:

  • List[Any]

    The list of affected (updated or inserted) keys.

Raises:

  • UnsupportedFeatureError

    If the object does not support handling updated keys.