Разнос по библиотекам + прикручиваем odb из redkitty
This commit was merged in pull request #5.
This commit is contained in:
64
src/database/author_s.h
Normal file
64
src/database/author_s.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// file : hello/person.hxx
|
||||
// copyright : not copyrighted - public domain
|
||||
|
||||
#ifndef AUTHOR_S_H
|
||||
#define AUTHOR_S_H
|
||||
|
||||
#include "database_global.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/query.hxx>
|
||||
|
||||
#pragma db object
|
||||
class DATABASE_EXPORT Author_S
|
||||
{
|
||||
public:
|
||||
Author_S() = default;
|
||||
|
||||
Author_S(const QString& firstN,
|
||||
const QString& lastN,
|
||||
const unsigned short age) :
|
||||
m_firstName(firstN),
|
||||
m_lastName(lastN),
|
||||
m_age(age)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned long long id() const { return m_id; }
|
||||
QString firstName() const { return m_firstName; }
|
||||
QString lastName() const { return m_lastName; }
|
||||
unsigned short age() const { return m_age; }
|
||||
|
||||
QString full_name() const { return m_firstName + " " + m_lastName; }
|
||||
|
||||
void age(unsigned short age) { m_age = age; }
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
private:
|
||||
#pragma db id auto
|
||||
quint64 m_id;
|
||||
|
||||
QString m_firstName;
|
||||
QString m_lastName;
|
||||
quint8 m_age;
|
||||
};
|
||||
|
||||
#pragma db view object(Author_S)
|
||||
struct person_stat
|
||||
{
|
||||
#pragma db column("count(" + Author_S::m_id + ")")
|
||||
std::size_t count;
|
||||
|
||||
#pragma db column("min(" + Author_S::m_age + ")")
|
||||
unsigned short min_age;
|
||||
|
||||
#pragma db column("max(" + Author_S::m_age + ")")
|
||||
unsigned short max_age;
|
||||
};
|
||||
|
||||
#endif // AUTHOR_S_H
|
||||
Reference in New Issue
Block a user