Add a task implementation to delete items

This commit is contained in:
eikek
2021-08-14 19:31:36 +02:00
parent 4901276c66
commit 50706c3d6d
5 changed files with 104 additions and 12 deletions

View File

@ -9,6 +9,7 @@ package docspell.store.records
import cats.data.NonEmptyList
import cats.effect.Sync
import cats.implicits._
import fs2.Stream
import docspell.common._
import docspell.store.qb.DSL._
@ -388,6 +389,11 @@ object RItem {
def findById(itemId: Ident): ConnectionIO[Option[RItem]] =
run(select(T.all), from(T), T.id === itemId).query[RItem].option
def findDeleted(collective: Ident, chunkSize: Int): Stream[ConnectionIO, RItem] =
run(select(T.all), from(T), T.cid === collective && T.state === ItemState.deleted)
.query[RItem]
.streamWithChunkSize(chunkSize)
def checkByIdAndCollective(itemId: Ident, coll: Ident): ConnectionIO[Option[Ident]] =
Select(T.id.s, from(T), T.id === itemId && T.cid === coll).build.query[Ident].option

View File

@ -83,10 +83,10 @@ trait UserTaskStore[F[_]] {
*
* Unlike `updateTask`, this ensures that there is at most one task
* of some name in the db. Multiple same tasks (task with same
* name) may not be allowed to run, dependening on what they do.
* name) may not be allowed to run, depending on what they do.
* This is not ensured by the database, though.
*
* If there are currently mutliple tasks with same name as `ut` for
* If there are currently multiple tasks with same name as `ut` for
* the user `account`, they will all be removed and the given task
* inserted!
*/