Last active
June 8, 2018 01:40
-
-
Save ryansgot/57035025e0d41f2273489f710a1c4ad4 to your computer and use it in GitHub Desktop.
ForSure DB CRUD For the Impatient (Kotlin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val uuid = UUID.randomUUID().toString() | |
// create (upsert) | |
ForSure.employeesTable() | |
.set().firstName("Some").lastName("Name").uuid(uuid) | |
.save() | |
//retrieve | |
val api = ForSure.employeesTable().api | |
val retriever = ForSure.employeesTable().get() | |
if (retriever.moveToFirst()) { | |
do { | |
var retrievedUUID = api.uuid(retriever) | |
var firstName = api.firstName(retriever) | |
var lastName = api.lastName(retriever) | |
} while(retriever.moveToNext()) | |
} | |
retriever.close() | |
// update (upsert) | |
ForSure.employeesTable() | |
.find().byUuid(uuid) | |
.then().set().firstName("First").lastName("Last") | |
.save() | |
// delete | |
ForSure.employeesTable() | |
.find().byFirstName("First") | |
.then().set().hardDelete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment