Find notes by tags in notes list
This commit is contained in:
@@ -132,5 +132,9 @@ internal class NoteRepositoryImpl(private val db: Database) : NoteRepository {
|
||||
.mapColumns(isDistinct = true) { it.name } as List<String>
|
||||
}
|
||||
|
||||
override fun count(userId: Int) = db.notes.count { it.userId eq userId }
|
||||
override fun count(userId: Int, tag: String?): Int {
|
||||
if (tag == null) return db.notes.count { it.userId eq userId }
|
||||
return db.sequenceOf(Tags)
|
||||
.count { it.name eq tag and (it.note.userId eq userId) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user