# How to check if a query condition exists?

  1. Construct the query using the collection's QueryBuilder class
  2. use the exists api to check if the query condition exists

For example to check wether an open lottery with name starting with "metastay" exists:


 

val lotteryQry = LotteryQuery().open.is(true).lotteryName.startsWith("metastay")
val conditionExists = lotteryQry.exists