Skip to content

Commit 68b014f

Browse files
committed
RELEASE 1.0.0
1 parent c2d6b3b commit 68b014f

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name := "simple-mongo"
33

44
organization := "com.sfxcode.nosql"
55

6-
version := "0.9.3-SNAPSHOT"
6+
version := "1.0.0"
77

8-
crossScalaVersions := Seq( "2.12.2","2.11.10")
8+
crossScalaVersions := Seq( "2.12.2","2.11.11")
99

1010
scalaVersion := "2.12.2"
1111

@@ -24,7 +24,7 @@ parallelExecution in Test := false
2424

2525
// Test
2626

27-
libraryDependencies += "org.specs2" %% "specs2-core" % "3.8.9" % "test"
27+
libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test"
2828

2929
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" % "test"
3030

@@ -37,7 +37,7 @@ libraryDependencies += "org.json4s" %% "json4s-native" % "3.5.2" % "test"
3737
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "2.1.0"
3838

3939

40-
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"
40+
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.7.1"
4141

4242

4343
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))

src/main/scala/com/sfxcode/nosql/mongo/MongoDAO.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sfxcode.nosql.mongo
22

33
import com.sfxcode.nosql.mongo.operation.Search
4-
import org.mongodb.scala.{ MongoCollection, MongoDatabase }
4+
import org.mongodb.scala.{ Document, MongoCollection, MongoDatabase }
55

66
import scala.reflect.ClassTag
77

@@ -14,4 +14,7 @@ abstract class MongoDAO[A](database: MongoDatabase, collectionName: String)(impl
1414

1515
protected def coll: MongoCollection[A] = collection
1616

17+
// internal object for raw document access
18+
object Raw extends MongoDAO[Document](database, collectionName)
19+
1720
}

src/main/scala/com/sfxcode/nosql/mongo/operation/Search.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class Search[A]()(implicit ct: ClassTag[A]) extends Crud[A] {
1111

1212
protected def coll: MongoCollection[A]
1313

14-
def find(filter: Bson = Document()): FindObservable[A] = coll.find(filter)
14+
def find(filter: Bson = Document(), sort: Bson = Document(), projection: Bson = Document()): FindObservable[A] = coll.find(filter).sort(sort).projection(projection)
1515

1616
def findById(oid: Any): FindObservable[A] = {
1717
oid match {

src/test/scala/com/sfxcode/nosql/mongo/tour/Database.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ object Database extends ObservableImplicits {
2222

2323
object BookDAO extends MongoDAO[Book](database, "books")
2424

25+
class BookDocumentDAO extends MongoDAO[Document](database, "books")
26+
2527
object LineDAO extends MongoDAO[Line](database, "lines")
2628

2729
object PersonDAO extends MongoDAO[Person](database, "person")

src/test/scala/com/sfxcode/nosql/mongo/tour/TestTour.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,9 @@ object TestTour extends App {
3838

3939
println(book.equals(scalaBook))
4040

41+
val bookJson = new BookDocumentDAO().find(projection = Map("title" -> 1)).headResult().toJson()
42+
43+
println(bookJson)
44+
4145
}
4246

0 commit comments

Comments
 (0)