I'm creating a SQLite table using qxOrm. I want a column data be unique (not the primary column). How can I do that?
Thank you very much!
#ifndef _PERSON_H_
#define _PERSON_H_
class person
{
public:
long id;
QString firstName;
QString lastName;
QDateTime birthDate;
person() : id(0) { ; }
virtual ~person() { ; }
};
QX_REGISTER_HPP_MY_TEST_EXE(person, qx::trait::no_base_class_defined, 0)
#endif // _PERSON_H_
#include "precompiled.h" // Precompiled-header with '#include <QxOrm.h>' and '#include "export.h"'
#include "person.h" // Class definition 'person'
#include <QxOrm_Impl.h> // Automatic memory leak detection and boost serialization export macro
QX_REGISTER_CPP_MY_TEST_EXE(person) // This macro is necessary to register 'person' class in QxOrm context
namespace qx {
template <> void register_class(QxClass<person> & t)
{
t.setName("t_person"); // 'person' C++ class is mapped to 't_person' database table
t.id(& person::id, "id"); // Register 'person::id' <=> primary key in your database
t.data(& person::firstName, "first_name"); // Register 'person::firstName' property mapped to 'first_name' database column name
t.data(& person::lastName, "last_name"); // Register 'person::lastName' property mapped to 'last_name' database column name
t.data(& person::birthDate, "birth_date"); // Register 'person::birthDate' property mapped to 'birth_date' database column name
}}
qx::dao::create_table<person>(&dbConnection);
qx::dao::create_table<person>(&dbConnection);
QxOrm library doesn't provide a generator to create and to update automatically tables into database.
Indeed, qx::dao::create_table<T> function must be used only to create prototypes or samples.
Users browsing this forum: No registered users and 5 guests