/* eslint-disable @typescript-eslint/no-unused-vars */
import { ICollection, IQueryCriteria, UniqueID } from "@shared/contexts";
import Firebird from "node-firebird";

import {
  IRepository,
  IRepositoryQueryBuilder,
} from "../../domain/repositories";
import { IFirebirdAdapter } from "./FirebirdAdapter";

export abstract class FirebirdRepository<T> implements IRepository<T> {
  protected queryBuilder: IRepositoryQueryBuilder;
  protected transaction: Firebird.Transaction;
  protected adapter: IFirebirdAdapter;

  public constructor(props: {
    adapter: IFirebirdAdapter;
    transaction: Firebird.Transaction;
  }) {
    this.adapter = props.adapter;
    this.transaction = props.transaction;
    this.queryBuilder = this.adapter.queryBuilder;
  }

  protected getById(id: UniqueID): Promise<T | null> {
    throw new Error("[FirebirdRepository] getById not implemented!");
  }

  protected findAll(queryCriteria?: IQueryCriteria): Promise<ICollection<T>> {
    throw new Error("[FirebirdRepository] findAll not implemented!");
  }

  protected save(t: T): Promise<void> {
    throw new Error("[FirebirdRepository] save not implemented!");
  }

  /* protected remove(t: T): Promise<boolean> {
        throw new Error('[FirebirdRepository] remove not implemented!');
    }*/

  protected removeById(id: UniqueID): Promise<void> {
    throw new Error("[FirebirdRepository] removeById not implemented!");
  }

  protected async _getBy(
    modelName: string,
    field: string,
    value: any,
    params: any = {}
  ): Promise<T> {
    throw new Error("[FirebirdRepository] _getBy not implemented!");
  }

  protected async _getById(
    modelName: string,
    id: UniqueID | string,
    params: any = {}
  ): Promise<T> {
    throw new Error("[FirebirdRepository] _getById not implemented!");
  }

  protected async _findAll(
    modelName: string,
    queryCriteria?: IQueryCriteria,
    params: any = {}
  ): Promise<{ rows: any[]; count: number }> {
    console.time("_findAll");
    throw new Error("[FirebirdRepository] _findAll not implemented!");
  }

  protected async _exists(
    modelName: string,
    field: string,
    value: any,
    params: any = {}
  ): Promise<boolean> {
    throw new Error("[FirebirdRepository] _exists not implemented!");
  }

  protected async _save(
    modelName: string,
    id: UniqueID,
    data: any,
    params: any = {}
  ): Promise<void> {
    throw new Error("[FirebirdRepository] _save not implemented!");
  }

  protected async _removeById(
    modelName: string,
    id: UniqueID,
    force: boolean = false,
    params: any = {}
  ): Promise<void> {
    throw new Error("[FirebirdRepository] _removeById not implemented!");
  }
}
