Skip to content

Instantly share code, notes, and snippets.

@bwmcadams
Created January 3, 2011 20:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwmcadams/763876 to your computer and use it in GitHub Desktop.
Save bwmcadams/763876 to your computer and use it in GitHub Desktop.
Select a limited set of fields with Casbah
import com.mongodb.casbah.Imports._
val conn = MongoConnection()
val db = conn("test")
val coll = db("foo")
for (x <- coll.find(MongoDBObject("_id" -> new ObjectId("4cd2d357c575954934c5a975")),
MongoDBObject("x" -> 1))) println(x)
/** { "_id" : { "$oid" : "4cd2d357c575954934c5a975"} , "a" : [ 1.0 , 8.0 , 10.0 , 3.0 , 5.0 , 6.0 , 123.0]} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment