Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
Update Casbah deps to 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rktoomey committed Jun 24, 2012
1 parent a4cfdcd commit 7c3c073
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -28,6 +28,8 @@ Please remove all references to `repo.novus.com` from your build files. After 0

"com.novus" %% "salat" % "1.9-SNAPSHOT"

- Casbah support has been upgraded to [2.3.0](http://notes.implicit.ly/post/25727213706/casbah-2-3-0)

## Play 2 plugin

Are you using Play framework? Make sure to see our [Play support][play-salat] wiki page, and check out Leon Radley's plugin at [leon/play-salat][play-salat-plugin].
Expand Down
17 changes: 8 additions & 9 deletions project/SalatBuild.scala
Expand Up @@ -8,7 +8,7 @@ object SalatBuild extends Build {

val testDeps = Seq(specs2, logbackCore, logbackClassic)
val utilDeps = Seq(slf4jApi) ++ testDeps
val coreDeps = Seq(mongoJava, casbah_core, lift_json, commonsLang) ++ testDeps
val coreDeps = Seq(casbah, lift_json, commonsLang) ++ testDeps

lazy val salat = Project(
id = "salat",
Expand Down Expand Up @@ -124,16 +124,15 @@ object Dependencies {
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.6.4"
val logbackCore = "ch.qos.logback" % "logback-core" % "1.0.0" % "test"
val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.0.0" % "test"
val mongoJava = "org.mongodb" % "mongo-java-driver" % "2.7.3"
val casbah = "org.mongodb" %% "casbah" % "2.3.0"
// TODO: these dependencies are not yet available for 2.9.2
// causes complaining:
// Setting version to 2.9.2
// [info] Set current project to salat (in build file:/home/rose/workspace/salat/)
// [warn] Potentially incompatible versions of dependencies of {file:/home/rose/workspace/salat/}salat-core:
// [warn] org.scala-lang: 2.9.2, 2.9.1
// [warn] Potentially incompatible versions of dependencies of {file:/home/rose/workspace/salat/}salat:
// [warn] org.scala-lang: 2.9.2, 2.9.1
val casbah_core = "com.mongodb.casbah" % "casbah-core_2.9.1" % "2.1.5-1"
// Setting version to 2.9.2
// [info] Set current project to salat (in build file:/home/rose/workspace/salat/)
// [warn] Potentially incompatible versions of dependencies of {file:/home/rose/workspace/salat/}salat-core:
// [warn] org.scala-lang: 2.9.2, 2.9.1
// [warn] Potentially incompatible versions of dependencies of {file:/home/rose/workspace/salat/}salat:
// [warn] org.scala-lang: 2.9.2, 2.9.1
val lift_json = "net.liftweb" % "lift-json_2.9.1" % "2.4"
}

Expand Down
10 changes: 5 additions & 5 deletions salat-core/src/main/scala/com/novus/salat/dao/SalatDAO.scala
Expand Up @@ -117,15 +117,15 @@ abstract class SalatDAO[ObjectType <: AnyRef, ID <: Any](val collection: MongoCo
* @return list of child ids matching parent id and search criteria
*/
def idsForParentId(parentId: ID, query: DBObject = MongoDBObject.empty): List[ChildID] = {
childDao.collection.find(parentIdQuery(parentId) ++ query, MongoDBObject("_id" -> 1)).map(_.expand[ChildID]("_id")(mcid).get).toList
childDao.collection.find(parentIdQuery(parentId) ++ query, MongoDBObject("_id" -> 1)).map(_.expand[ChildID]("_id").get).toList
}

/** @param parentIds list of parent ids
* @param query object for which to search
* @return list of child ids matching parent ids and search criteria
*/
def idsForParentIds(parentIds: List[ID], query: DBObject = MongoDBObject.empty): List[ChildID] = {
childDao.collection.find(parentIdsQuery(parentIds) ++ query, MongoDBObject("_id" -> 1)).map(_.expand[ChildID]("_id")(mcid).get).toList
childDao.collection.find(parentIdsQuery(parentIds) ++ query, MongoDBObject("_id" -> 1)).map(_.expand[ChildID]("_id").get).toList
}

/** @param parentId parent id
Expand Down Expand Up @@ -282,7 +282,7 @@ abstract class SalatDAO[ObjectType <: AnyRef, ID <: Any](val collection: MongoCo
*/
def insert(docs: Traversable[ObjectType], wc: WriteConcern = defaultWriteConcern) = if (docs.nonEmpty) {
val dbos = docs.map(_grater.asDBObject(_)).toList
val wr = collection.insert(dbos, wc)
val wr = collection.insert(dbos: _*)
val lastError = wr.getCachedLastError
if (lastError == null || (lastError != null && lastError.ok())) {
dbos.map {
Expand All @@ -301,7 +301,7 @@ abstract class SalatDAO[ObjectType <: AnyRef, ID <: Any](val collection: MongoCo
* @return list of IDs
*/
def ids[A <% DBObject](query: A): List[ID] = {
collection.find(query, MongoDBObject("_id" -> 1)).map(_.expand[ID]("_id")(mid).get).toList
collection.find(query, MongoDBObject("_id" -> 1)).map(_.expand[ID]("_id").get).toList
}

/** @param t object for which to search
Expand Down Expand Up @@ -459,7 +459,7 @@ abstract class SalatDAO[ObjectType <: AnyRef, ID <: Any](val collection: MongoCo
val builder = List.newBuilder[P]
results.foreach {
r =>
r.expand[P](field)(m).foreach(builder += _)
r.expand[P](field).foreach(builder += _)
}

builder.result()
Expand Down

0 comments on commit 7c3c073

Please sign in to comment.