use $lookup.pipeline in DailyPuzzle
parent
8d91d6d41c
commit
7ad920ca65
|
@ -100,7 +100,7 @@ final class ClasApi(
|
|||
as = "clas",
|
||||
local = "clasId",
|
||||
foreign = "_id",
|
||||
pipeline = List(
|
||||
pipe = List(
|
||||
$doc(
|
||||
"$match" -> $doc(
|
||||
"$expr" -> $doc("$in" -> $arr(teacher, "$teachers"))
|
||||
|
|
|
@ -355,10 +355,10 @@ trait dsl {
|
|||
simple(from.name, as, local, foreign)
|
||||
def simple(from: AsyncColl, as: String, local: String, foreign: String): Bdoc =
|
||||
simple(from.name.value, as, local, foreign)
|
||||
def pipeline(from: Coll, as: String, local: String, foreign: String, pipeline: List[Bdoc]): Bdoc =
|
||||
def pipeline(from: String, as: String, local: String, foreign: String, pipe: List[Bdoc]): Bdoc =
|
||||
$doc(
|
||||
"$lookup" -> $doc(
|
||||
"from" -> from.name,
|
||||
"from" -> from,
|
||||
"as" -> as,
|
||||
"let" -> $doc("local" -> s"$$$local"),
|
||||
"pipeline" -> {
|
||||
|
@ -366,10 +366,14 @@ trait dsl {
|
|||
"$match" -> $doc(
|
||||
"$expr" -> $doc($doc("$eq" -> $arr(s"$$$foreign", "$$local")))
|
||||
)
|
||||
) :: pipeline
|
||||
) :: pipe
|
||||
}
|
||||
)
|
||||
)
|
||||
def pipeline(from: Coll, as: String, local: String, foreign: String, pipe: List[Bdoc]): Bdoc =
|
||||
pipeline(from.name, as, local, foreign, pipe)
|
||||
def pipeline(from: AsyncColl, as: String, local: String, foreign: String, pipe: List[Bdoc]): Bdoc =
|
||||
pipeline(from.name.value, as, local, foreign, pipe)
|
||||
}
|
||||
|
||||
implicit class ElementBuilderLike(val field: String)
|
||||
|
|
|
@ -188,7 +188,7 @@ final class MsgApi(
|
|||
as = "msgs",
|
||||
local = "_id",
|
||||
foreign = "tid",
|
||||
pipeline = List(
|
||||
pipe = List(
|
||||
$doc("$sort" -> $sort.desc("date")),
|
||||
$doc("$limit" -> 11),
|
||||
$doc("$project" -> msgProjection)
|
||||
|
|
|
@ -58,24 +58,16 @@ final private[puzzle] class DailyPuzzle(
|
|||
Project($doc("ids" -> true, "_id" -> false)),
|
||||
UnwindField("ids"),
|
||||
PipelineOperator(
|
||||
$doc(
|
||||
"$lookup" -> $doc(
|
||||
"from" -> colls.puzzle.name.value,
|
||||
"as" -> "puzzle",
|
||||
"let" -> $doc("id" -> "$ids"),
|
||||
"pipeline" -> $arr(
|
||||
$doc(
|
||||
"$match" -> $doc(
|
||||
"$expr" -> $doc(
|
||||
$doc("$eq" -> $arr("$_id", "$$id"))
|
||||
)
|
||||
)
|
||||
),
|
||||
$doc(
|
||||
"$match" -> $doc(
|
||||
Puzzle.BSONFields.day $exists false,
|
||||
Puzzle.BSONFields.themes $ne PuzzleTheme.oneMove.key.value
|
||||
)
|
||||
$lookup.pipeline(
|
||||
from = colls.puzzle,
|
||||
as = "puzzle",
|
||||
local = "ids",
|
||||
foreign = "_id",
|
||||
pipe = List(
|
||||
$doc(
|
||||
"$match" -> $doc(
|
||||
Puzzle.BSONFields.day $exists false,
|
||||
Puzzle.BSONFields.themes $ne PuzzleTheme.oneMove.key.value
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -257,7 +257,7 @@ final class RelayApi(
|
|||
as = "rounds",
|
||||
local = "_id",
|
||||
foreign = "tourId",
|
||||
pipeline = List(
|
||||
pipe = List(
|
||||
$doc("$sort" -> $doc("startedAt" -> 1, "startsAt" -> 1, "name" -> 1))
|
||||
)
|
||||
)
|
||||
|
|
|
@ -30,7 +30,7 @@ final class RelayPager(tourRepo: RelayTourRepo, roundRepo: RelayRoundRepo)(impli
|
|||
as = "round",
|
||||
local = "_id",
|
||||
foreign = "tourId",
|
||||
pipeline = List(
|
||||
pipe = List(
|
||||
$doc(
|
||||
"$sort" -> $doc(
|
||||
"startedAt" -> -1,
|
||||
|
|
|
@ -86,7 +86,7 @@ final class UblogPaginator(
|
|||
as = "blog",
|
||||
local = "blog",
|
||||
foreign = "_id",
|
||||
pipeline = List(
|
||||
pipe = List(
|
||||
$doc(
|
||||
"$match" -> $doc(
|
||||
"$expr" -> $doc("$gte" -> $arr("$tier", UblogBlog.Tier.LOW))
|
||||
|
|
Loading…
Reference in New Issue