Skip to content

Commit

Permalink
Exposed json variable in Materialized
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Jun 9, 2024
1 parent 1a83cb5 commit 4d7e84e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/lightdb/index/Materialized.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fabric.Json
import fabric.rw.{Asable, RW}
import lightdb.{Document, Id}

class Materialized[D <: Document[D]](json: Json) {
case class Materialized[D <: Document[D]](json: Json) {
def get[F](index: Index[F, D]): Option[F] = json.get(index.fieldName).map(_.as[F](index.rw))
def apply[F](index: Index[F, D]): F = get(index).getOrElse(throw new NullPointerException(s"${index.fieldName} not found in $json"))
def as[T](implicit rw: RW[T]): T = json.as[T]
Expand Down
2 changes: 1 addition & 1 deletion sql/src/main/scala/lightdb/sql/SQLSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ trait SQLSupport[D <: Document[D]] extends IndexSupport[D] {
val map = index.fields.filter(_.materialize).map { index =>
index.fieldName -> getJson(rs, index.fieldName)
}.toMap
new Materialized[D](Obj(map))
Materialized[D](Obj(map))
}
}
iterator.toList
Expand Down

0 comments on commit 4d7e84e

Please sign in to comment.