From 3e1be995ade413456c4bf2684e97b14703870312 Mon Sep 17 00:00:00 2001 From: sipp11 Date: Wed, 2 Oct 2019 03:52:40 +0900 Subject: [PATCH] DB init --- app/build.gradle | 3 ++- .../java/co/zzyzx/sensorlogger/Database.kt | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/co/zzyzx/sensorlogger/Database.kt diff --git a/app/build.gradle b/app/build.gradle index 84ca48f..102bfb9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,12 +24,13 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.github.kittinunf.fuel:fuel: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.exposed:exposed:0.16.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' diff --git a/app/src/main/java/co/zzyzx/sensorlogger/Database.kt b/app/src/main/java/co/zzyzx/sensorlogger/Database.kt new file mode 100644 index 0000000..ec2bd38 --- /dev/null +++ b/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) : IntEntity(id) { + companion object : IntEntityClass(Records) + + var timestamp by Records.timestamp + var sensor by Records.sensor + var data by Records.data +} \ No newline at end of file