tritus / persist Goto Github PK
View Code? Open in Web Editor NEWPersist data in kotlin
Persist data in kotlin
We will do one to many in another issue
We want to be able to store list of storable properties.
Example :
@Persist
interface TestData {
@PersistentId
val id: Long
val names: List<String>
}
@Persist
interface AnotherTestData {
@PersistentId
val id: Long
val testDatas: List<TestData>
}
We want to be able to observe properties of the record. We should find a nice way of getting a Flow from a property.
The aim is multiplatform. Let's try it. It may be already compatible. The goal is to try it.
Put explicit errors in case of wrong usage of the annotations
sqldelight supports many other types than string and long. We want to implement them all.
CREATE TABLE some_types (
some_long INTEGER, -- Stored as INTEGER in db, retrieved as Long
some_double REAL, -- Stored as REAL in db, retrieved as Double
some_string TEXT, -- Stored as TEXT in db, retrieved as String
some_blob BLOB, -- Stored as BLOB in db, retrieved as ByteArray
some_int INTEGER AS Int, -- Stored as INTEGER in db, retrieved as Int
some_short INTEGER AS Short, -- Stored as INTEGER in db, retrieved as Short
some_float REAL AS Float -- Stored as REAL in db, retrieved as Float
);
https://cashapp.github.io/sqldelight/multiplatform_sqlite/types/
We want to be able to have var in the interface defining the data. When setting a new value to the var, we should save the value in the db.
example :
fun TestData(name: String?, description: String): TestData {
val database = PersistDatabaseProvider.getDatabase()
val rawData = database.testData_DataQueries.transactionWithResult<TestData_Data> {
database.testData_DataQueries.createNew(name, description)
database.testData_DataQueries.getLastRecord().executeAsOne()
}
return retrieve(rawData.id)
}
fun TestData(id) = object : TestData {
override val id = id
override val name: kotlin.String?
get() =
PersistDatabaseProvider.getDatabase().testData_DataQueries.getName(id).executeAsOne().name
override var description: kotlin.String
get() =
PersistDatabaseProvider.getDatabase().testData_DataQueries.getDescription(id).executeAsOne()
set(value) = PersistDatabaseProvider.getDatabase().testData_DataQueries.setDescription(
value,
id
)
}
Explicit the setup and usage of persist in the readme.
We want IntelliJ to generate classes and methods after annotating with @persist without having to compile manually.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.