forked from zio/zio-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sql.scala
30 lines (22 loc) · 953 Bytes
/
Sql.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package zio.sql
trait Sql extends SelectModule with DeleteModule with UpdateModule with ExprModule with TableModule { self =>
/*
* (SELECT *, "foo", table.a + table.b AS sum... FROM table WHERE cond) UNION (SELECT ... FROM table)
* UNION ('1', '2', '3')
* ORDER BY table.a ASC, foo, sum DESC
* LIMIT 200
* OFFSET 100
* UPDATE table SET ...
* INSERT ... INTO table
* DELETE ... FROM table
*
* SELECT ARBITRARY(age), COUNT(*) FROM person GROUP BY age
*/
def select[F, A, B <: SelectionSet[A]](selection: Selection[F, A, B]): SelectBuilder[F, A, B] =
SelectBuilder(selection)
def deleteFrom[F[_], A, B](table: Table.Source.Aux[F, A, B]): Delete[A] = Delete(table, true)
def update[A](table: Table.Aux[A]): UpdateBuilder[A] = UpdateBuilder(table)
def renderDelete(delete: self.Delete[_]): String
def renderRead(read: self.Read[_]): String
def renderUpdate(update: self.Update[_]): String
}