quill-generic-parent


License

License

GroupId

GroupId

com.github.ajozwik
ArtifactId

ArtifactId

quill-generic-parent_2.12
Last Version

Last Version

0.1.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

quill-generic-parent
quill-generic-parent
Project URL

Project URL

https://github.com/ajozwik/quill-generic
Project Organization

Project Organization

com.github.ajozwik
Source Code Management

Source Code Management

https://github.com/ajozwik/quill-generic

Download quill-generic-parent_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.ajozwik/quill-generic-parent_2.12/ -->
<dependency>
    <groupId>com.github.ajozwik</groupId>
    <artifactId>quill-generic-parent_2.12</artifactId>
    <version>0.1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.ajozwik/quill-generic-parent_2.12/
implementation 'com.github.ajozwik:quill-generic-parent_2.12:0.1.2.1'
// https://jarcasting.com/artifacts/com.github.ajozwik/quill-generic-parent_2.12/
implementation ("com.github.ajozwik:quill-generic-parent_2.12:0.1.2.1")
'com.github.ajozwik:quill-generic-parent_2.12:jar:0.1.2.1'
<dependency org="com.github.ajozwik" name="quill-generic-parent_2.12" rev="0.1.2.1">
  <artifact name="quill-generic-parent_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.ajozwik', module='quill-generic-parent_2.12', version='0.1.2.1')
)
libraryDependencies += "com.github.ajozwik" % "quill-generic-parent_2.12" % "0.1.2.1"
[com.github.ajozwik/quill-generic-parent_2.12 "0.1.2.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8

provided (1)

Group / Artifact Type Version
com.sksamuel.scapegoat : scalac-scapegoat-plugin_2.12 jar 1.3.9

Project Modules

There are no modules declared in this project.

quill-generic support

Library of generic CRUD operation for quill library. Only dynamic queries are supported.

Codacy Badge Build Status Maven Central Maven Central Coverage Status

Always when you start new project you must to write a lot of boilerplate code for handling simple CRUD operations. Purpose of this library is to support creating CRUD repository with Quill library.

Purpose of CRUD operations - Repository - where F is monad like scala.util.Try/monix.eval.Task/scala.concurrent.Future :

package pl.jozwik.quillgeneric.quillmacro

import scala.language.higherKinds

trait RepositoryWithGeneratedId[K, T <: WithId[K]] extends BaseRepository[K, T] {
  def create(entity: T, generatedId: Boolean = true): F[K]

  def createAndRead(entity: T, generatedId: Boolean = true): F[T]

  def createOrUpdate(entity: T, generatedId: Boolean = true): F[K]

  def createOrUpdateAndRead(entity: T, generatedId: Boolean = true): F[T]
}

trait RepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K]] extends Repository[K, T]

trait Repository[K, T <: WithId[K]] extends BaseRepository[K, T] {
  def create(entity: T): F[K]

  def createAndRead(entity: T): F[T]

  def createOrUpdate(entity: T): F[K]

  def createOrUpdateAndRead(entity: T): F[T]
}

trait BaseRepository[K, T <: WithId[K]] extends WithMonad {

  def all: F[Seq[T]]

  def read(id: K): F[Option[T]]

  def readUnsafe(id: K): F[T]

  def update(t: T): F[Long]

  def updateAndRead(t: T): F[T]

  def delete(id: K): F[Long]

}

trait WithMonad {
  type F[_]
}

Because macro is created in compile time - we need to know primary key. Case class for database entity has to have field id - the primary key WithId If you have composite key - it has to extends io.getquill.Embedded and one of traits CompositeKey

General Repository and RepositoryCompositeKey is designed for manual handling of primary key. If database generate for you key - use RepositoryWithGeneratedId

Current we support Try:

And monix Task:

Synchronized and monix repositories are generated automatically by sbt-quill-crud-generic, see build.sbt in quill-macro-example

Versions

Version
0.1.2.1
0.1.0