# How to define a mongo collection?

  1. Open the respective .kmongo file.

    For example to define Lottery collection, open LotteryMongo.kmongo file in eclipse.

  2. Define the collection using keyword collection as follows:

    collection Lottery(
    	property lotteryName : String
    	property participantList:String* // * denotes a List 
    	property open:Boolean
    )
    

    Note: Dont forget to save the file

  3. enter sbt shell, run compile command to access the mongo dml classes, such as Row, Query, Writer etc.

# Sample Usage:

//To insert a row in db
val row = LotteryRow(
  lotteryName = "metastayLotteryContest",
  participantList = List("Rekha", "Aashish", "Lek"),
  open = true
)
LotteryWriter().save(row)

Note: By default mongo runs on port 27017, override the configuration in mongo module's conf.

Ex: default settings in lotterymongo.conf

host="localhost"
port=27017
dbName="lotterymongo"
// if the db 'lotterymongo' is to be accessed by specific userName, provide the userName and password below
// userName=<userName>
// password=<password>