Go to file
Hamed Masafi 1f1cd29fc2 travis ci icon on readme 2018-01-08 13:05:26 +03:30
doc wip: Database model moved to TableModel 2017-05-27 20:10:10 +04:30
include database creation polish 2018-01-08 12:38:10 +03:30
src merge upstream 2018-01-08 12:40:16 +03:30
test wip: join 2017-09-10 18:48:20 +04:30
.gitignore Initial commit 2016-03-09 11:05:49 +03:30
.travis.yml ammend 2018-01-08 12:54:25 +03:30
Doxyfile readme changes 2016-06-10 12:44:31 +04:30
LICENSE Initial commit 2016-03-09 11:05:49 +03:30
README.md travis ci icon on readme 2018-01-08 13:05:26 +03:30
nut.pri database creation polish 2018-01-08 12:38:10 +03:30
nut.pro ammend 2018-01-08 12:54:25 +03:30
nut.qbs qbs file added 2018-01-08 12:38:23 +03:30
nut.qdocconf order phrase completed 2016-06-05 16:52:26 +04:30

README.md

Nut

Build Status

Advanced, Powerful and easy to use ORM for Qt5

Features:

  • Easy to use
  • Support PosgtreSQL, MySQL, SQLite and Microsoft Sql Server
  • Automatically create and update database
  • IDE auto complete support, No hard-code nedded
  • Table join detect

Sample Codes

Read data from database:

auto q = db.posts()->createQuery();
q->setWhere(Post::idField() == postId);
auto posts = q->toList();
// now posts is a QList<Post*> contain all posts in
//  database that has id equal to postId variable
auto post = q->first();
// post is first row in database that its id is equal to postId

Adding to database:

Post *newPost = new Post;
newPost->setTitle("post title");

db.posts()->append(newPost);

for(int i = 0 ; i < 3; i++){
    Comment *comment = new Comment;
    comment->setMessage("comment #" + QString::number(i));

    newPost->comments()->append(comment);
}
db.saveChanges();

Modify database data:

auto q = db.posts()->createQuery();
q->setWhere(Post::idField() == postId);
Post *post = q->first();

if(post) {
    post->setTitle("new name");
    db.saveChanges();
} else {
    qWarning("No post found!");
}

For more information read Wiki.