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
import reactivemongo.core.commands._ | |
import reactivemongo.bson._ | |
import reactivemongo.bson.DefaultBSONHandlers._ | |
import reactivemongo.bson.BSONInteger | |
import reactivemongo.bson.BSONString | |
import scala.Some | |
// { listDatabases: 1 } | |
/* | |
listDatabases returns a document for each database |
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
import reactivemongo.bson._ | |
// BigDecimal and BigInteger BSON Handlers – the right way :) | |
object BSONBigDecimalBigInteger { | |
implicit object BigIntHandler extends BSONDocumentReader[BigInt] with BSONDocumentWriter[BigInt] { | |
def write(bigInt: BigInt): BSONDocument = BSONDocument( | |
"signum" -> bigInt.signum, | |
"value" -> BSONBinary(bigInt.toByteArray, Subtype.UserDefinedSubtype)) | |
def read(doc: BSONDocument): BigInt = BigInt( |
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
package controllers | |
import play.api.mvc._ | |
import play.api.Play.current | |
import play.modules.reactivemongo._ | |
import customcommands._ | |
import reactivemongo.bson._ | |
import reactivemongo.bson.handlers.DefaultBSONHandlers._ | |
import play.api.libs.json._ | |
import reactivemongo.api.gridfs._ |
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
package bugs | |
import play.api.libs.iteratee._ | |
import scala.util.Failure | |
import scala.util.Success | |
import scala.concurrent.Future | |
import scala.concurrent.Promise | |
object StackOverflowErrorBug { | |
import scala.concurrent.ExecutionContext.Implicits.global |
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
libraryDependencies ++= Seq( | |
"io.netty" % "netty" % "3.3.1.Final", | |
"com.typesafe.akka" % "akka-actor_2.10.0-RC2" % "2.1.0-RC2", | |
"play" % "play-iteratees_2.10" % "2.1-SNAPSHOT", | |
"ch.qos.logback" % "logback-core" % "1.0.0", | |
"ch.qos.logback" % "logback-classic" % "1.0.0", | |
"org.specs2" % "specs2_2.10.0-RC2" % "1.12.2" % "test", | |
"junit" % "junit" % "4.8" % "test" | |
) |
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
// finds all documents with lastName = Godbillon and replace lastName with GODBILLON | |
def findAndModify() = { | |
val selector = BSONDocument( | |
"lastName" -> BSONString("Godbillon")) | |
val modifier = BSONDocument( | |
"$set" -> BSONDocument("lastName" -> BSONString("GODBILLON"))) | |
val command = FindAndModify( | |
collection.collectionName, |
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
package play.modules.mongodb | |
import com.mongodb.casbah.MongoConnection | |
import com.mongodb.casbah.MongoCollection | |
import com.mongodb.casbah.MongoDB | |
import play.api._ | |
class MongoPlugin(app :Application) extends Plugin { | |
lazy val helper :MongoHelper = { | |
val parsedConf = MongoPlugin.parseConf(app) |
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
// Full source code available on https://github.com/sgodbillon/minitwitter | |
var nmnLocation = '/path/to/node-mongodb-native' | |
var Db = require(nmnLocation).Db, | |
Server = require(nmnLocation).Server; | |
var host = 'localhost'; | |
var port = 27017; |