|
1 | 1 | <h1 align="center">db-messiah-extra</h1>
|
2 | 2 | <h3 align="center">Extra Utils for Db Messiah, kotlin lib. for enterprise database development</h3>
|
| 3 | +<p align="center"> |
| 4 | + readme code snippets are |
| 5 | + <a href="https://github.com/urosjarc/db-messiah/blob/master/src/tutorials/kotlin/Test_README.md">autogenerated</a> |
| 6 | + and |
| 7 | + <a href="https://github.com/urosjarc/db-messiah/blob/master/src/tutorials/kotlin/Test_README.kt">tested</a><br> |
| 8 | + +<b>15</b> <a href="https://github.com/urosjarc/db-messiah/blob/master/src/e2e">e2e</a> tests with <b>100%</b> instruction coverage |
| 9 | +</p> |
3 | 10 | <br>
|
4 | 11 | <br>
|
5 | 12 | <table width="100%" border="0">
|
6 | 13 | <tr>
|
7 |
| - <td width="50%"> |
| 14 | + <td width="33%"> |
8 | 15 | <h3 align="center"><a href="https://github.com/urosjarc/db-messiah">db-messiah</a></h3>
|
9 | 16 | <p align="center">Kotlin lib. for enterprise database development</p>
|
10 | 17 | </td>
|
11 |
| - <td width="50%"> |
| 18 | + <td width="33%" align="center"> |
| 19 | + <p><a href="#get-started">Get started</a></p> |
| 20 | + <p><a href="#specifications">Specifications</a></p> |
| 21 | + <p><a href="#arhitecture">Arhitecture</a></p> |
| 22 | + <p><a href="https://urosjarc.github.io/db-messiah-extra/">Documentation</a></p> |
| 23 | + </td> |
| 24 | + <td width="33%"> |
12 | 25 | <h3 align="center"><a href="https://github.com/urosjarc/db-analyser">db-analyser</a></h3>
|
13 | 26 | <p align="center">GUI for db analysis, to help you create complex JOIN statements for SQL or db-messiah.
|
14 | 27 | </td>
|
|
20 | 33 | <h2 align="center">Get started</h2>
|
21 | 34 |
|
22 | 35 | ```kotlin
|
23 |
| -implementation("com.urosjarc:db-messiah-extra:0.0.1") |
| 36 | +implementation("com.urosjarc:db-messiah-extra-extra:0.0.1") |
24 | 37 | ```
|
25 | 38 |
|
26 |
| -<br><h3 align="center">DB Serializers</h3> |
| 39 | +<br><h3 align="center">Domain</h3> |
27 | 40 |
|
28 | 41 | ```kotlin
|
29 |
| -/** SQLITE */ |
30 |
| - |
31 |
| -val sqliteSerializer = SqliteSerializer( |
32 |
| - globalSerializers = BasicTS.sqlite + KotlinxTimeTS.sqlite, |
33 |
| - ... |
| 42 | +@Serializable |
| 43 | +data class MyTable( |
| 44 | + @Contextual |
| 45 | + val pk: UUID = UUID.randomUUID(), |
| 46 | + val instant: kotlinx.datetime.Instant, |
| 47 | + val localDate: kotlinx.datetime.LocalDate, |
| 48 | + val localTime: kotlinx.datetime.LocalTime, |
34 | 49 | )
|
35 | 50 |
|
36 |
| -/** POSTGRESQL */ |
| 51 | +``` |
37 | 52 |
|
| 53 | +<br><h3 align="center">DB Serializers</h3> |
| 54 | + |
| 55 | +```kotlin |
38 | 56 | val sqliteSerializer = SqliteSerializer(
|
39 | 57 | globalSerializers = BasicTS.sqlite + KotlinxTimeTS.sqlite,
|
40 |
| - ... |
| 58 | + tables = listOf(Table(MyTable::pk)), |
41 | 59 | )
|
42 | 60 | ```
|
43 | 61 |
|
44 | 62 | <br><h3 align="center">JSON Serializers</h3>
|
45 | 63 |
|
46 |
| - |
47 | 64 | ```kotlin
|
48 | 65 | /** JSON */
|
49 | 66 |
|
50 | 67 | val json = Json {
|
51 |
| - serializersModule = SerializersModule { |
| 68 | + serializersModule = SerializersModule { |
52 | 69 | contextual(InstantJS)
|
53 | 70 | contextual(LocalDateJS)
|
54 | 71 | contextual(LocalTimeJS)
|
55 | 72 | contextual(UUIDJS)
|
56 | 73 | }
|
57 | 74 | }
|
58 | 75 |
|
59 |
| -val jsonStr = json.encodeToString(...) |
60 |
| -val obj = json.decodeFromString<...>(...) |
61 |
| - |
62 |
| -/** KTOR */ |
63 | 76 |
|
64 |
| -install(ContentNegotiation) { |
65 |
| - json(Json { |
66 |
| - serializersModule = SerializersModule { |
67 |
| - contextual(InstantJS) |
68 |
| - contextual(LocalDateJS) |
69 |
| - contextual(LocalTimeJS) |
70 |
| - contextual(UUIDJS) |
71 |
| - } |
72 |
| - }) |
| 77 | +val dtNow = Clock.System.now().toLocalDateTime(timeZone = TimeZone.UTC) |
| 78 | +val myTable = MyTable( |
| 79 | + instant = Clock.System.now(), |
| 80 | + localDate = dtNow.date, |
| 81 | + localTime = dtNow.time |
| 82 | +) |
| 83 | + |
| 84 | +val jsonStr = json.encodeToString(myTable) |
| 85 | +val obj = json.decodeFromString<MyTable>(jsonStr) |
| 86 | +assert(obj == myTable) |
| 87 | + |
| 88 | +/** KTOR */ |
| 89 | +embeddedServer(Netty, port = 8080, host = "0.0.0.0") { |
| 90 | + install(ContentNegotiation) { |
| 91 | + json(Json { |
| 92 | + serializersModule = SerializersModule { |
| 93 | + contextual(InstantJS) |
| 94 | + contextual(LocalDateJS) |
| 95 | + contextual(LocalTimeJS) |
| 96 | + contextual(UUIDJS) |
| 97 | + } |
| 98 | + }) |
| 99 | + } |
73 | 100 | }
|
74 | 101 | ```
|
75 | 102 |
|
76 |
| -<br><h3 align="center">Features</h3> |
| 103 | +<br><br><h2 align="center">Specifications</h3> |
| 104 | + |
| 105 | +| Class | COLUMN | Databases | db-messiah-extra | JSON | |
| 106 | +|:-------------:|:------------:|:------------------------------------:|:---------------------------:|:-----------:| |
| 107 | +| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | KotlinxInstantTS. DATETIME | InstantJS | |
| 108 | +| Instant | TIMESTAMP | Derby, Postgres, Oracle | KotlinxInstantTS. TIMESTAMP | InstantJS | |
| 109 | +| LocalDateTime | :x: | :x: | :x: | :x: | |
| 110 | +| LocalDate | DATE | :white_check_mark: | KotlinxLocalDateTS. DATE | LocalDateJS | |
| 111 | +| LocalTime | TIME | :white_check_mark: but Oracle | KotlinxTimeTS.TIME | LocalDateJS | |
| 112 | +| LocalTime | NUMBER(8, 0) | Oracle | KotlinxTimeTS. NUMBER8 | LocalTimeJS | |
| 113 | +| UUID | db-messiah | db-messiah | db-messiah | UUIDJS | |
77 | 114 |
|
78 |
| -| Class | COLUMN | Databases | db-messiah-extra | JSON | |
79 |
| -|:---------:|:------------:|:------------------------------------:|:---------------------------:|:-----------:| |
80 |
| -| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | KotlinxInstantTS. DATETIME | InstantJS | |
81 |
| -| Instant | TIMESTAMP | Derby, Postgres, Oracle | KotlinxInstantTS. TIMESTAMP | InstantJS | |
82 |
| -| LocalDate | DATE | :white_check_mark: | KotlinxLocalDateTS. DATE | LocalDateJS | |
83 |
| -| LocalTime | TIME | :white_check_mark: but Oracle | KotlinxTimeTS.TIME | LocalDateJS | |
84 |
| -| LocalTime | NUMBER(8, 0) | Oracle | KotlinxTimeTS. NUMBER8 | LocalTimeJS |> |
85 |
| -| UUID | db-messiah | db-messiah | db-messiah | UUIDJS |> |
| 115 | +<br><br><h2 align="center">Arhitecture</h3> |
| 116 | + |
| 117 | +```text |
| 118 | +src/main/kotlin/com/urosjarc/dbmessiah/extra/ |
| 119 | +|-- kotlinx |
| 120 | +| |-- InstantJS.kt............| java.time.Instant serializer for kotlinx.serialization |
| 121 | +| |-- LocalDateJS.kt..........| java.time.LocalDate serializer for kotlinx.serialization |
| 122 | +| |-- LocalTimeJS.kt..........| java.time.LocalTime serializer for kotlinx.serialization |
| 123 | +| `-- UUIDJS.kt...............| java.utils.UUID serializer for kotlinx.serialization |
| 124 | +`-- serializers |
| 125 | + |-- KotlinxInstantTS.kt.....| kotlinx.datetime.Instant type serializer for db-messiah |
| 126 | + |-- KotlinxLocalDateTS.kt...| kotlinx.datetime.LocalDate type serializer for db-messiah |
| 127 | + |-- KotlinxLocalTimeTS.kt...| kotlinx.datetime.LocalTime type serializer for db-messiah |
| 128 | + `-- KotlinxTimeTS.kt........| kotlinx.datetime.Time type serializer for db-messiah |
| 129 | +``` |
| 130 | + |
| 131 | +<br><br><h2 align="center">Sources</h2> |
| 132 | + |
| 133 | +```text |
| 134 | +src/ |
| 135 | +|-- main...............................| Already described in architecture. |
| 136 | +`-- test |
| 137 | + |-- kotlin |
| 138 | + | |-- impl |
| 139 | + | | |-- Test_Contract.kt.......| Testing interface for all db tests. |
| 140 | + | | |-- Test_Db2.kt |
| 141 | + | | |-- Test_Derby.kt |
| 142 | + | | |-- Test_H2.kt |
| 143 | + | | |-- Test_Maria.kt |
| 144 | + | | |-- Test_Mssql.kt |
| 145 | + | | |-- Test_Mysql.kt |
| 146 | + | | |-- Test_Oracle.kt |
| 147 | + | | |-- Test_Postgresql.kt |
| 148 | + | | `-- Test_Sqlite.kt |
| 149 | + | |-- Test_InstantJS.kt |
| 150 | + | |-- Test_LocalDateJS.kt |
| 151 | + | |-- Test_LocalTimeJS.kt |
| 152 | + | |-- Test_README.kt.............| Code from where README.md is generated. |
| 153 | + | |-- Test_README.md.............| Template from where README.md is generated. |
| 154 | + | |-- Test_UUIDJS.kt |
| 155 | + | `-- utils |
| 156 | + | |-- domain.kt |
| 157 | + | |-- Schemas.kt |
| 158 | + | `-- Serializers.kt |
| 159 | + `-- resources |
| 160 | + `-- log4j2.xml |
| 161 | +``` |
0 commit comments