<?php

namespace Apexl\Io\Interfaces;

use Apexl\Io\Dtos\EntityField;
use Apexl\Io\Exceptions\RecordNotFoundException;
use Apexl\Vault\Interfaces\ResultInterface;

interface EntityOperatorInterface
{
    /**
     * @throws RecordNotFoundException
     */
    public function load(int|string $id, bool $skipAccessCheck = false): array;

    /**
     * @throws RecordNotFoundException
     */
    public function loadBy(string $field, mixed $value, bool $skipAccessCheck = false): array;

    public function loadMultiple(
        array $conditions = [],
        array $orderBy = [],
        ?int $limit = null,
        ?int $offset = null,
    ): array;

    public function delete(int|string $id): ResultInterface;

    public function store(array $data): bool|array;

    /** Fields the operator must not write when updating an existing row. */
    public function setReadOnlyFields(array $fields): static;

    /**
     * @return EntityField[]
     */
    public function entityFields(): array;

}
