# How to define a composite data?

  1. Open the respective .kdata file.

    For example to define Lottery data as a composite data type, open LotteryData.kdata file in eclipse.

  2. Define the composite data using keyword data as follows:

    data Lottery(
    	lotteryName:String,
    	amount:Int,
    	participantList:String*, // * denotes List data type i.e. List[String] in this case
    	winner:String?, // ? denotes Option data type i.e. Option[String] in this case
    	status:String
    )
    

    Note: Dont forget to save the file

  3. enter sbt shell, run compile command to access the data class (ex: Lottery.scala).

# Sample Usage:


 







val row = LotteryReadQuery().lotteryName.is("LOTTO-1").findOne.get
val lotteryData = new Lottery( 
  lotteryName = row.lotteryName,
  amount = row.amount,
  participantList = row.participantList.map(_.name),
  status = if (row.open) "OPEN" else "CLOSED",
  winner = row.winner
  )