https://kotlinlang.org logo
#exposed
Title
# exposed
t

tjb

02/19/2019, 6:38 AM
Copy code
return transaction {
      PostDAO.wrapRows(
        Posts
          .innerJoin(PostsTags, {Posts.id}, {<http://PostsTags.post|PostsTags.post>})
          .innerJoin(Tags, {Tags.id}, {PostsTags.tag})
          .selectAll()
          .andWhere {
            Posts.title like "%$query%" or (Tags.name inList tags)
          }
          .withDistinct()
      ).map {
        it.toModel()
      }
      .distinct()
      .toList()
    }
t

tapac

02/19/2019, 9:06 AM
It's better to use
select {}
instead of
selectAll().andWhere{}
.
select
is the alias to sql
where
.
👍 1
t

tjb

02/19/2019, 4:30 PM
i will refactor! thank you @tapac
2 Views