Last active
October 17, 2018 14:03
-
-
Save ryansgot/e8b4ee4764a37e69ce859c3ab0d9a17a to your computer and use it in GitHub Desktop.
ForSureDB CRUD for the Impatient (Java)
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
String uuid = UUID.randomUUID().toString(); | |
// create (upsert) | |
ForSure.employeesTable() | |
.set().firstName("Some").lastName("Name").uuid(uuid) | |
.save(); | |
// retrieve | |
EmployeesTable api = ForSure.employeesTable().getApi(); | |
Retriever retriever = ForSure.employeesTable().get(); | |
if (retriever.moveToFirst()) { | |
do { | |
String retrievedUUID = api.uuid(retriever); | |
String firstName = api.firstName(retriever); | |
String 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