Core Models¶
The core module provides the BaseModel class, which serves as the foundation for all other database models in the system.
class
automation.dbmodels.core.BaseModel(*args, **kwargs)Base model class for all database models.
It provides common utility methods for CRUD operations and serialization.
Inherits from peewee.Model and uses a dynamic database proxy.
read(id)Select a single record by its ID.
Parameters:
- id (int|str): The primary key of the record.
Returns:
- Model: The model instance if found, otherwise None.
read_all()Retrieves all records from the table.
Returns:
- list: A list of serialized dictionaries representing all records.
put(id, **fields)Updates a record by its ID.
Parameters:
- id (str): The primary key of the record to update.
- fields: Keyword arguments representing the fields to update.
Returns:
- query: The execution result.
id_exists(id)Checks if a record exists by its ID.
Parameters:
- id (int|str): Record ID.
Returns:
- bool: True if the record exists, False otherwise.