Function orderBy

Summary

#include <orm_lib/inc/drogon/orm/Mapper.h>

(1) Mapper< T > & orderBy(const std::string &colName, const SortOrder &order=SortOrder::ASC)

(2) Mapper< T > & orderBy(size_t colIndex, const SortOrder &order=SortOrder::ASC)

Function overload

Synopsis

#include <orm_lib/inc/drogon/orm/Mapper.h>

Mapper< T > & orderBy(const std::string &colName, const SortOrder &order=SortOrder::ASC)

Description

Set the order of the results.

Parameters:

colName - the column name, the results are sorted by that column

order - Ascending or descending order

Return
Mapper<T>& The Mapper itself.

Mentioned in

Source

Lines 1512-1535 in orm_lib/inc/drogon/orm/Mapper.h. Line 148 in orm_lib/inc/drogon/orm/Mapper.h.

template <typename T>
inline Mapper<T> &Mapper<T>::orderBy(const std::string &colName,
                                     const SortOrder &order)
{
    if (orderByString_.empty())
    {
        orderByString_ =
            utils::formattedString(" order by %s", colName.c_str());
        if (order == SortOrder::DESC)
        {
            orderByString_ += " desc";
        }
    }
    else
    {
        orderByString_ += ",";
        orderByString_ += colName;
        if (order == SortOrder::DESC)
        {
            orderByString_ += " desc";
        }
    }
    return *this;
}

Synopsis

#include <orm_lib/inc/drogon/orm/Mapper.h>

Mapper< T > & orderBy(size_t colIndex, const SortOrder &order=SortOrder::ASC)

Description

Set the order of the results.

Parameters:

colIndex - the column index, the results are sorted by that column

order - Ascending or descending order

Return
Mapper<T>& The Mapper itself.

Mentioned in

Source

Lines 1536-1542 in orm_lib/inc/drogon/orm/Mapper.h. Line 158 in orm_lib/inc/drogon/orm/Mapper.h.

template <typename T>
inline Mapper<T> &Mapper<T>::orderBy(size_t colIndex, const SortOrder &order)
{
    std::string colName = T::getColumnName(colIndex);
    assert(!colName.empty());
    return orderBy(colName, order);
}





Add Discussion as Guest

Log in to DocsForge