Function Criteria

Summary

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

(1) template <typename T>
    Criteria(const std::string &colName, const CompareOperator &opera, T &&arg)

(2) template <typename T>
    Criteria(const std::string &colName, const CompareOperator &opera, const std::vector< T > &args)

(3) template <typename T>
    Criteria(const std::string &colName, const CompareOperator &opera, std::vector< T > &&args)

(4) template <typename T>
    Criteria(const std::string &colName, const CompareOperator &opera, std::vector< T > &args)

(5) template <typename T>
    Criteria(const std::string &colName, T &&arg)

(6) Criteria(const std::string &colName, const CompareOperator &opera)

(7) Criteria(const std::string &colName, CompareOperator &opera)

(8) Criteria(const std::string &colName, CompareOperator &&opera)

(9) Criteria(const Json::Value &json) noexcept(false)

(10) Criteria()

Function overload

Synopsis

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

template <typename T>
Criteria(const std::string &colName, const CompareOperator &opera, T &&arg)

Description

Construct a new Criteria object.

Template Parameters:

T - the type of the object to be compared with.

Parameters:

colName - The name of the column.

opera - The type of the comparison.

arg - The object to be compared with.

Source

Lines 80-117 in orm_lib/inc/drogon/orm/Criteria.h.

template <typename T>
Criteria(const std::string &colName, const CompareOperator &opera, T &&arg)
{
    assert(opera != CompareOperator::IsNotNull &&
           opera != CompareOperator::IsNull);
    conditionString_ = colName;
    switch (opera)
    {
        case CompareOperator::EQ:
            conditionString_ += " = $?";
            break;
        case CompareOperator::NE:
            conditionString_ += " != $?";
            break;
        case CompareOperator::GT:
            conditionString_ += " > $?";
            break;
        case CompareOperator::GE:
            conditionString_ += " >= $?";
            break;
        case CompareOperator::LT:
            conditionString_ += " < $?";
            break;
        case CompareOperator::LE:
            conditionString_ += " <= $?";
            break;
        case CompareOperator::Like:
            conditionString_ += " like $?";
            break;
        case CompareOperator::IsNull:
        case CompareOperator::IsNotNull:
        default:
            break;
    }
    outputArgumentsFunc_ = [=](internal::SqlBinder &binder) {
        binder << arg;
    };
}

Synopsis

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

template <typename T>
Criteria(const std::string &colName, const CompareOperator &opera, const std::vector< T > &args)

Description

No description yet.

Source

Lines 119-140 in orm_lib/inc/drogon/orm/Criteria.h.

template <typename T>
Criteria(const std::string &colName,
         const CompareOperator &opera,
         const std::vector<T> &args)
{
    assert(opera == CompareOperator::In && args.size() > 0);
    conditionString_ = colName + " in (";
    for (size_t i = 0; i < args.size(); ++i)
    {
        if (i < args.size() - 1)
            conditionString_.append("$?,");
        else
            conditionString_.append("$?");
    }
    conditionString_.append(")");
    outputArgumentsFunc_ = [args](internal::SqlBinder &binder) {
        for (auto &arg : args)
        {
            binder << arg;
        }
    };
}

Synopsis

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

template <typename T>
Criteria(const std::string &colName, const CompareOperator &opera, std::vector< T > &&args)

Description

No description yet.

Source

Lines 142-164 in orm_lib/inc/drogon/orm/Criteria.h.

template <typename T>
Criteria(const std::string &colName,
         const CompareOperator &opera,
         std::vector<T> &&args)
{
    assert(opera == CompareOperator::In && args.size() > 0);
    conditionString_ = colName + " in (";
    for (size_t i = 0; i < args.size(); ++i)
    {
        if (i < args.size() - 1)
            conditionString_.append("$?,");
        else
            conditionString_.append("$?");
    }
    conditionString_.append(")");
    outputArgumentsFunc_ =
        [args = std::move(args)](internal::SqlBinder &binder) {
            for (auto &arg : args)
            {
                binder << arg;
            }
        };
}

Synopsis

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

template <typename T>
Criteria(const std::string &colName, const CompareOperator &opera, std::vector< T > &args)

Description

No description yet.

Source

Lines 166-172 in orm_lib/inc/drogon/orm/Criteria.h.

template <typename T>
Criteria(const std::string &colName,
         const CompareOperator &opera,
         std::vector<T> &args)
    : Criteria(colName, opera, (const std::vector<T> &)args)
{
}

Synopsis

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

template <typename T>
Criteria(const std::string &colName, T &&arg)

Description

Construct a new Criteria object presenting a equal expression.

Template Parameters:

T - The type of the object to be equal to.

Parameters:

colName - The name of the column.

arg - The object to be equal to.

Source

Lines 181-185 in orm_lib/inc/drogon/orm/Criteria.h.

template <typename T>
Criteria(const std::string &colName, T &&arg)
    : Criteria(colName, CompareOperator::EQ, arg)
{
}

Synopsis

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

Criteria(const std::string &colName, const CompareOperator &opera)

Description

Construct a new Criteria object presenting a expression without parameters.

Parameters:

colName - The name of the column.

opera - The type of the comparison. it must be one of the following:

CompareOperator::IsNotNull
CompareOperator::IsNull

Source

Lines 198-214 in orm_lib/inc/drogon/orm/Criteria.h.

Criteria(const std::string &colName, const CompareOperator &opera)
{
    assert(opera == CompareOperator::IsNotNull ||
           opera == CompareOperator::IsNull);
    conditionString_ = colName;
    switch (opera)
    {
        case CompareOperator::IsNull:
            conditionString_ += " is null";
            break;
        case CompareOperator::IsNotNull:
            conditionString_ += " is not null";
            break;
        default:
            break;
    }
}

Synopsis

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

Criteria(const std::string &colName, CompareOperator &opera)

Description

No description yet.

Source

Lines 215-218 in orm_lib/inc/drogon/orm/Criteria.h.

Criteria(const std::string &colName, CompareOperator &opera)
    : Criteria(colName, (const CompareOperator &)opera)
{
}

Synopsis

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

Criteria(const std::string &colName, CompareOperator &&opera)

Description

No description yet.

Source

Lines 219-222 in orm_lib/inc/drogon/orm/Criteria.h.

Criteria(const std::string &colName, CompareOperator &&opera)
    : Criteria(colName, (const CompareOperator &)opera)
{
}

Synopsis

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

Criteria(const Json::Value &json) noexcept(false)

Description

Construct a new Criteria object.

Parameters:

json - A json object representing the criteria

Note
the json object must be a array of three items, the first is the name of the field, the second is the comparison operator and the third is the value to be compared. The valid operators are "=","<",">","<=",">=","!=","in" for example: ["id","=",1] means 'id = 1' ["id","!=",null] means 'id is not null' ["user_name","in",["Tom","Bob"]] means 'user_name in ('Tom', 'Bob')' ["price","<",1000] means 'price < 1000'

Source

Line 238 in orm_lib/inc/drogon/orm/Criteria.h.

Synopsis

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

Criteria()

Description

No description yet.

Source

Lines 240-242 in orm_lib/inc/drogon/orm/Criteria.h.

Criteria()
{
}





Add Discussion as Guest

Log in to DocsForge