Created
June 17, 2011 08:09
-
-
Save xuwei-k/1031057 to your computer and use it in GitHub Desktop.
casbah2.1.5-1で、DBからDynamicDBObjectで取得する場合のコード
This file contains hidden or 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
import com.mongodb.casbah.Imports._ | |
import com.mongodb.casbah.dynamic._ | |
val db = MongoConnection("IPアドレスとか")("データベース名") | |
val col = db("コレクション名") | |
implicit def dynamicConverter(obj:DBObject) = new { | |
def toDynamic = DynamicDBObject.empty ++= obj | |
} | |
val obj = col( DBObject("name" -> "Scalaちゃん") ).toDynamic | |
println( obj.得意呪文.typed[String].getOrElse("得意呪文なし") ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment