seeker
seeker

Reputation: 69

Querying MongoDB with scala/lift

I am using Scala/Lift for an app that I am developing.

I am using MongoDB for the backend database.

Now, how do I query the mongodb to get records from a collection? I want to use the returned records to fill up a select control.

I basically want to do: db.users.find() and fill a select control with the id's of each record.

How do I do this in scala/lift?

Code snippets will be helpful.

Thanks!

Upvotes: 3

Views: 1937

Answers (1)

tylerweir
tylerweir

Reputation: 1302

From the Lift Wiki - http://www.assembla.com/wiki/show/liftweb/Mongo_Record_Basics

JsonDSL example:

import net.liftweb.json.JsonDSL._

Person.findAll(("name" -> "joe") ~ ("age" -> 27))

QueryBuilder example:

import com.mongodb._

val qry = QueryBuilder.start("name").is("joe")
  .put("age").is(27)
  .get

Person.findAll(qry)

For further questions, please refer to the Lift Google Group[1] and Wiki[2]. These are the official support channels.

[1] - https://groups.google.com/forum/#!forum/liftweb

[2] - http://www.assembla.com/wiki/show/liftweb/

Upvotes: 1

Related Questions