Browse Source

DB init

master
sipp11 5 years ago
parent
commit
3e1be995ad
  1. 1
      app/build.gradle
  2. 20
      app/src/main/java/co/zzyzx/sensorlogger/Database.kt

1
app/build.gradle

@ -30,6 +30,7 @@ dependencies {
implementation 'com.github.kittinunf.fuel:fuel:2.1.0' implementation 'com.github.kittinunf.fuel:fuel:2.1.0'
implementation 'com.github.kittinunf.fuel:fuel-android:2.1.0' implementation 'com.github.kittinunf.fuel:fuel-android:2.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-M2' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-M2'
implementation 'org.jetbrains.exposed:exposed:0.16.1'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'

20
app/src/main/java/co/zzyzx/sensorlogger/Database.kt

@ -0,0 +1,20 @@
package co.zzyzx.sensorlogger
import org.jetbrains.exposed.dao.EntityID
import org.jetbrains.exposed.dao.IntEntity
import org.jetbrains.exposed.dao.IntEntityClass
import org.jetbrains.exposed.dao.IntIdTable
object Records : IntIdTable() {
val timestamp = datetime("timestamp")
val sensor = varchar("sensor", 20)
val data = text("data:")
}
class Record(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<Record>(Records)
var timestamp by Records.timestamp
var sensor by Records.sensor
var data by Records.data
}
Loading…
Cancel
Save