mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Generate a query string given an expression
Initialize share record and improve tests.
This commit is contained in:
@ -11,6 +11,7 @@ import java.time.{Instant, LocalDate}
|
||||
|
||||
import docspell.common._
|
||||
import docspell.common.syntax.all._
|
||||
import docspell.query.{ItemQuery, ItemQueryParser}
|
||||
import docspell.totp.Key
|
||||
|
||||
import com.github.eikek.calev.CalEvent
|
||||
@ -142,6 +143,11 @@ trait DoobieMeta extends EmilDoobieMeta {
|
||||
|
||||
implicit val metaByteSize: Meta[ByteSize] =
|
||||
Meta[Long].timap(ByteSize.apply)(_.bytes)
|
||||
|
||||
implicit val metaItemQuery: Meta[ItemQuery] =
|
||||
Meta[String].timap(s => ItemQueryParser.parseUnsafe(s))(q =>
|
||||
q.raw.getOrElse(ItemQueryParser.unsafeAsString(q.expr))
|
||||
)
|
||||
}
|
||||
|
||||
object DoobieMeta extends DoobieMeta {
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2020 Eike K. & Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package docspell.store.records
|
||||
|
||||
import cats.data.NonEmptyList
|
||||
|
||||
import docspell.common._
|
||||
import docspell.query.ItemQuery
|
||||
import docspell.store.qb._
|
||||
|
||||
final case class RShare(
|
||||
id: Ident,
|
||||
cid: Ident,
|
||||
query: ItemQuery,
|
||||
enabled: Boolean,
|
||||
password: Option[Password],
|
||||
publishedAt: Timestamp,
|
||||
publishedUntil: Timestamp,
|
||||
views: Int,
|
||||
lastAccess: Option[Timestamp]
|
||||
) {}
|
||||
|
||||
object RShare {
|
||||
|
||||
final case class Table(alias: Option[String]) extends TableDef {
|
||||
val tableName = "item_share";
|
||||
|
||||
val id = Column[Ident]("id", this)
|
||||
val cid = Column[Ident]("cid", this)
|
||||
val query = Column[ItemQuery]("query", this)
|
||||
val enabled = Column[Boolean]("enabled", this)
|
||||
val password = Column[Password]("password", this)
|
||||
val publishedAt = Column[Timestamp]("published_at", this)
|
||||
val publishedUntil = Column[Timestamp]("published_until", this)
|
||||
val views = Column[Int]("views", this)
|
||||
val lastAccess = Column[Timestamp]("last_access", this)
|
||||
|
||||
val all: NonEmptyList[Column[_]] =
|
||||
NonEmptyList.of(
|
||||
id,
|
||||
cid,
|
||||
query,
|
||||
enabled,
|
||||
password,
|
||||
publishedAt,
|
||||
publishedUntil,
|
||||
views,
|
||||
lastAccess
|
||||
)
|
||||
}
|
||||
|
||||
val T: Table = Table(None)
|
||||
def as(alias: String): Table = Table(Some(alias))
|
||||
|
||||
}
|
Reference in New Issue
Block a user