Advertisement
Guest User

scala mongo testing

a guest
Sep 9th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.70 KB | None | 0 0
  1. package moduleupload
  2.  
  3. import com.mongodb.casbah.Imports._
  4. import scalax.io._
  5.  
  6. object Transform {
  7.    val mongoClient = MongoConnection()
  8.    val db = mongoClient("test")
  9.    val modules = db("test")
  10.  
  11.    def main(args: Array[String]) {
  12.       val docs = modules find ("style" $exists false)
  13.       val (failed, altered) = docs.partition(work)
  14.  
  15.       //apparently does nothing
  16.       altered map {x =>
  17.          println("map: ")
  18.          println(x)
  19.       }
  20.  
  21.       //prints the documents
  22.       altered foreach {x =>
  23.          println("foreach: ")
  24.          println(x)
  25.       }
  26.    }
  27.  
  28.    def work(_item: DBObject): Boolean = {
  29.       val item: MongoDBObject = _item;
  30.       item.get("z").isEmpty
  31.    }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement