Skip to content

Qt Object-Relational Mapping (ORM) library for MySQL and SQLite

License

Notifications You must be signed in to change notification settings

wyyrepo/QOrmSql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QOrmSql

Qt Object-Relational Mapping (ORM) library for MySQL and SQLite

Usage Examples

In order to create model, you have to:

  • Use MyModel : public QOrmUserModel<MyModel> pattern
  • Create constructor with Q_INVOKABLE attribute and QObject * parameter
  • Use either QOrmPublic or QOrmPrivate to define class properties
  • Re-implement virtual methods tableName() and accept(QOrmModelVisitor &visitor)

Example with private fields:

class AndroidDevice : public QOrmUserModel<AndroidDevice>
{
    Q_OBJECT
public:
    Q_INVOKABLE AndroidDevice(QObject *parent);
    static QList<AndroidDevice *> findByName(const QString &name, QOrmDatabase *database = NULL);

    QString name() const;
    QString androidVersion() const;

    void setName(const QString &name);
    void setAndroidVersion(const QString &androidVersion);

protected:
    QString tableName() const;
    void accept(QOrmModelVisitor &visitor);

private:
    QOrmPrivate<QString> m_name;
    QOrmPrivate<QString> m_androidVersion;
};

Example with public fields:

class AndroidDevice : public QOrmUserModel<AndroidDevice>
{
    Q_OBJECT
public:
    Q_INVOKABLE AndroidDevice(QObject *parent);
    static QList<AndroidDevice *> findByName(const QString &name, QOrmDatabase *database = NULL);

    QOrmPublic<QString> name;
    QOrmPublic<QString> androidVersion;

protected:
    QString tableName() const;
    void accept(QOrmModelVisitor &visitor);
};

About

Qt Object-Relational Mapping (ORM) library for MySQL and SQLite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 93.7%
  • QMake 5.1%
  • C 1.2%