-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(example): Support getAll and search queries (#45)
Co-authored-by: Dragutin Marjanović <[email protected]>
- Loading branch information
1 parent
c0ac7cf
commit 5bd757f
Showing
6 changed files
with
186 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package example.api | ||
|
||
import zio.schema.{DeriveSchema, Schema} | ||
|
||
import java.time.LocalDateTime | ||
|
||
sealed trait Criteria | ||
|
||
object Criteria { | ||
implicit val schema: Schema[Criteria] = DeriveSchema.gen[Criteria] | ||
} | ||
|
||
final case class IntCriteria(field: IntFilter, operator: FilterOperator, value: Int) extends Criteria | ||
|
||
final case class DateCriteria(field: DateFilter, operator: FilterOperator, value: LocalDateTime) extends Criteria | ||
|
||
final case class CompoundCriteria( | ||
operator: CompoundOperator, | ||
filters: List[Criteria] | ||
) extends Criteria | ||
|
||
sealed trait FilterOperator | ||
|
||
object FilterOperator { | ||
case object GreaterThan extends FilterOperator | ||
case object LessThan extends FilterOperator | ||
case object EqualTo extends FilterOperator | ||
} | ||
|
||
sealed trait CompoundOperator | ||
|
||
object CompoundOperator { | ||
case object And extends CompoundOperator | ||
case object Or extends CompoundOperator | ||
} | ||
|
||
sealed trait IntFilter | ||
|
||
object IntFilter { | ||
case object Stars extends IntFilter { | ||
override def toString: String = "stars" | ||
} | ||
|
||
case object Forks extends IntFilter { | ||
override def toString: String = "forks" | ||
} | ||
} | ||
|
||
sealed trait DateFilter | ||
|
||
case object LastCommitAt extends DateFilter { | ||
override def toString: String = "lastCommitAt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import zio.elasticsearch.IndexName | ||
|
||
package object example { | ||
val Index: IndexName = IndexName("repositories") | ||
final val Index: IndexName = IndexName("repositories") | ||
final val organization: String = "zio" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters