# How to define a mongo collection?
PREREQUISITE
Open the respective .kmongo file.
For example to define Lottery collection, open LotteryMongo.kmongo file in eclipse.
Define the collection using keyword
collectionas follows:collection Lottery( property lotteryName : String property participantList:String* // * denotes a List property open:Boolean )Note: Dont forget to save the file
enter sbt shell, run
compilecommand 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>