mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Change custom fields for multiple items
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package docspell.store.records
|
||||
|
||||
import cats.data.NonEmptyList
|
||||
|
||||
import docspell.common._
|
||||
import docspell.store.impl.Column
|
||||
import docspell.store.impl.Implicits._
|
||||
@ -57,6 +59,6 @@ object RCustomFieldValue {
|
||||
def deleteByItem(item: Ident): ConnectionIO[Int] =
|
||||
deleteFrom(table, Columns.itemId.is(item)).update.run
|
||||
|
||||
def deleteValue(fieldId: Ident, item: Ident): ConnectionIO[Int] =
|
||||
deleteFrom(table, and(Columns.id.is(fieldId), Columns.itemId.is(item))).update.run
|
||||
def deleteValue(fieldId: Ident, items: NonEmptyList[Ident]): ConnectionIO[Int] =
|
||||
deleteFrom(table, and(Columns.id.is(fieldId), Columns.itemId.isIn(items))).update.run
|
||||
}
|
||||
|
@ -326,6 +326,15 @@ object RItem {
|
||||
def existsByIdAndCollective(itemId: Ident, coll: Ident): ConnectionIO[Boolean] =
|
||||
selectCount(id, table, and(id.is(itemId), cid.is(coll))).query[Int].unique.map(_ > 0)
|
||||
|
||||
def existsByIdsAndCollective(
|
||||
itemIds: NonEmptyList[Ident],
|
||||
coll: Ident
|
||||
): ConnectionIO[Boolean] =
|
||||
selectCount(id, table, and(id.isIn(itemIds), cid.is(coll)))
|
||||
.query[Int]
|
||||
.unique
|
||||
.map(_ == itemIds.size)
|
||||
|
||||
def findByIdAndCollective(itemId: Ident, coll: Ident): ConnectionIO[Option[RItem]] =
|
||||
selectSimple(all, table, and(id.is(itemId), cid.is(coll))).query[RItem].option
|
||||
|
||||
|
Reference in New Issue
Block a user