# How to run a distinct query?

  1. Construct the query using the collection's QueryBuilder class
  2. use the distinct on the required field.

For example:


 

val lotteryQry = LotteryQuery().open.is(true).lotteryName.startsWith("metastay")
val distinctLotteryNames = lotteryQry.lotteryName.distinct(LotteryReader().db)