#pragma once
#include <drogon/orm/BaseBuilder.h>
#include <string>
#include <type_traits>
namespace drogon
{
namespace orm
{
template <typename T, bool SelectAll, bool Single>
class TransformBuilder : public BaseBuilder<T, SelectAll, Single>
{
  public:
    TransformBuilder() = default;
    template <bool SI = Single, std::enable_if_t<SI, std::nullptr_t> = nullptr>
    TransformBuilder(const TransformBuilder<T, SelectAll, false> &tb)
    {
        this->from_ = tb.from_;
        this->columns_ = tb.columns_;
        this->filters_ = tb.filters_;
        this->limit_ = tb.limit_;
        this->offset_ = tb.offset_;
        this->orders_ = tb.orders_;
    }
    inline TransformBuilder &limit(std::uint64_t count)
    {
        this->limit_ = count;
        return *this;
    }
    inline TransformBuilder &offset(std::uint64_t count)
    {
        this->offset_ = count;
        return *this;
    }
    inline TransformBuilder &range(std::uint64_t from, std::uint64_t to)
    {
        this->offset_ = from;
        this->limit_ = to - from + 1;  
        return *this;
    }
    inline TransformBuilder &order(const std::string &column, bool asc = true)
    {
        this->assert_column(column);
        this->orders_.emplace_back(column, asc);
        return *this;
    }
    template <bool SI = Single, std::enable_if_t<!SI, std::nullptr_t> = nullptr>
    inline TransformBuilder<T, SelectAll, true> single() const
    {
        return {*this};
    }
};
}  
}  