In this recipe, we will see how we can use record
to connect our Lift application to a MongoDB database.
Before starting with this recipe, you will need to install MongoDB on your computer. You can download the appropriate installer for your OS from http://www.mongodb.org/downloads, and you can find installation instructions specific to your OS at http://docs.mongodb.org/manual/installation/.
Start a new blank project.
Edit the
build.sbt
file and add the following dependencies:"net.liftweb" %% "lift-mongodb" % liftVersion % "compile->default" withSources(), "net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile->default" withSources()
Add the following
import
statements in theBoot.scala
file:import net.liftweb.mongodb.{DefaultMongoIdentifier, MongoDB} import com.mongodb.Mongo
Add the following line in the
Boot.boot
method:MongoDB.defineDb(DefaultMongoIdentifier...