-2

如何在 slick 3.0 中进行此查询?

Select *,(SELECT COUNT(*) from flashcards WHERE setId = flashcards_sets.id ) as allCount,(SELECT COUNT(*) from flashcards WHERE studied = true AND setId = flashcards_sets.id ) as studiedCount FROM flashcards_sets;
4

1 回答 1

-1
private def filterByFlashCardQuery(id: Int): Query[FlashCards, FlashCard, Seq] =
    flashcards.filter(_.setId === id && _.studied = true)

def findByFlashcardLength(flashcardId: Int):Future[Int] = {
    try db.run(filterByFlashCardQuery(flashcardId).length.result)
    finally println("db.close")//db.close
  }

```

于 2015-12-10T01:41:03.750 回答