Created
April 11, 2012 00:56
-
-
Save alexy/2356032 to your computer and use it in GitHub Desktop.
finding and updating a mongo object with casbah, clueless edition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def putStat[T](id: String, k: String, v: T, coll: MongoCollection = ms): Unit = { | |
Console.err.println("putting mongo stat: _id->%s, %s->%s".format(id,k,v)) | |
val newVal = Map(k -> v) | |
coll.findOneByID(id) match { | |
case Some(obj) => coll.update(obj, obj + (k -> v)) | |
case _ => coll.insert(MongoDBObject("_id"->id, k->v)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment