Skip to content

Commit 9656b6e

Browse files
committed
MongoIndex support expires and text
1 parent bceb3fb commit 9656b6e

File tree

12 files changed

+54
-142
lines changed

12 files changed

+54
-142
lines changed

docs/src/main/paradox/features/converter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ BSON converter is used for bidirectional converting of BSON data.
5252

5353
### Example
5454

55-
@@snip [JodaConverterPlugin](/src/test/scala/com/sfxcode/nosql/mongo/converter/JodaConverterPlugin.scala)
55+
@@snip [JodaConverterPlugin](/src/test/scala/com/sfxcode/nosql/mongo/bson/JodaConverterPlugin.scala)
5656

docs/src/main/paradox/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Support Scala 2.12 and Scala 2.13.
3737
- [MongoDAO](dao/index.md)
3838
- [GridFSDAO](gridfs/index.md)
3939
- [Features](features/index.md)
40-
- [Tutorial](tutorial/index.md)
4140
- [Changes ](changes.md)
4241

4342
@@@

docs/src/main/paradox/tutorial/application.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/src/main/paradox/tutorial/database.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/src/main/paradox/tutorial/functions.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/src/main/paradox/tutorial/index.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/src/main/paradox/tutorial/setup.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

project/plugins.sbt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
addSbtPlugin("com.orrsella" % "sbt-stats" % "1.0.7")
2-
31
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
42

53
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
64

7-
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
8-
95
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
106

117
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
@@ -18,6 +14,8 @@ addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6")
1814

1915
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
2016

17+
addSbtPlugin("com.github.fedragon" % "sbt-todolist" % "0.7")
18+
2119
// paradox
2220
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.7.0")
2321

src/main/scala/com/sfxcode/nosql/mongo/database/MongoIndex.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ case class MongoIndex(
1010
ascending: Int,
1111
version: Int,
1212
namespace: String,
13-
keys: Map[String, Any] = Map()
13+
keys: Map[String, Any] = Map(),
14+
expire: Boolean,
15+
expireAfterSeconds: Long = -1,
16+
text: Boolean
1417
)
1518

1619
object MongoIndex extends ObservableIncludes {
@@ -63,7 +66,10 @@ object MongoIndex extends ObservableIncludes {
6366
},
6467
indexOptions("v").toString.toInt,
6568
indexOptions("ns").toString,
66-
indexOptions("key").asInstanceOf[Map[String, _]]
69+
indexOptions("key").asInstanceOf[Map[String, _]],
70+
indexOptions.get("expireAfterSeconds").isDefined,
71+
indexOptions.getOrElse("expireAfterSeconds", -1).toString.toLong,
72+
indexOptions.contains("textIndexVersion")
6773
)
6874
)
6975
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ abstract class Base[A]()(implicit ct: ClassTag[A]) extends LazyLogging {
7676

7777
def indexList(): List[MongoIndex] = MongoIndex.convertIndexDocumentsToMongoIndexList(listIndexes)
7878

79-
def hasIndexForField(fieldName: String): Boolean = MongoIndex.hasIndexForFieldWithName(listIndexes, fieldName)
79+
def indexForName(name: String): Option[MongoIndex] = indexList.find(_.name.equals(name))
80+
81+
def hasIndexForField(fieldName: String): Boolean = indexList().exists(index => index.key.equals(fieldName))
8082

8183
}

0 commit comments

Comments
 (0)