www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - hunt entity v2.1.0 released!

reply Brian <zoujiaqing gmail.com> writes:
Hunt Entity is an object-relational mapping (ORM) framework for 
dlang's database, support PostgreSQL / MySQL / SQLite.

This version added pagination for EQL's createQuery();

Example 1 for pagination:

```D

class User
{
     mixin MakeModel;

      AutoIncrement
      PrimaryKey
     int id;

     string name;
}

auto query = em.createQuery!User("SELECT * FROM User", new 
Pageable(0, 10));
auto page = query.getPageResult();

logDebug("Page NO: %s, size of Page: %s, Total Pages: %s, Total: 
%s".format(page.getNumber(), page.getSize(), 
page.getTotalPages(), page.getTotalElements()));

foreach (user; page.getContent())
{
     logDebug("User[%s] is: %s".format(user.id, user.name));
}

```


Example 2 for limit && offset :


```D

class User
{
     mixin MakeModel;

      AutoIncrement
      PrimaryKey
     int id;

     string name;
}

auto query = em.createQuery!User("SELECT * FROM 
User").setFirstResult(10).setMaxResults(20);

foreach (user; query.getResultList())
{
     logDebug("User[%s] is: %s".format(user.id, user.name));
}

```
Jan 09 2019
next sibling parent reply Brian <zoujiaqing gmail.com> writes:
Fix example code:
https://github.com/huntlabs/hunt-entity/wiki/Pagination

Github repo:
https://github.com/huntlabs/hunt-entity
Jan 09 2019
parent reply Martin Tschierschke <mt smartdolphin.de> writes:
On Wednesday, 9 January 2019 at 11:34:07 UTC, Brian wrote:
 Fix example code:
 https://github.com/huntlabs/hunt-entity/wiki/Pagination

 Github repo:
 https://github.com/huntlabs/hunt-entity
Is your work related to shark? https://code.dlang.org/packages/shark Regards mt.
Jan 09 2019
parent Brian <zoujiaqing gmail.com> writes:
On Wednesday, 9 January 2019 at 14:12:06 UTC, Martin Tschierschke 
wrote:
 On Wednesday, 9 January 2019 at 11:34:07 UTC, Brian wrote:
 Fix example code:
 https://github.com/huntlabs/hunt-entity/wiki/Pagination

 Github repo:
 https://github.com/huntlabs/hunt-entity
Is your work related to shark? https://code.dlang.org/packages/shark Regards mt.
No, shark library "Entity" define looks like hunt-entity history version. We team has hunt-database and hunt-sql support hunt-entity to work. hunt-entity is so powerfull ORM. shark is very simple, now.
Jan 09 2019
prev sibling parent Soulsbane <paul acheronsoft.com> writes:
On Wednesday, 9 January 2019 at 11:28:58 UTC, Brian wrote:
 Hunt Entity is an object-relational mapping (ORM) framework for 
 dlang's database, support PostgreSQL / MySQL / SQLite.

 [...]
Really cool! Thanks.
Jan 09 2019