Skip to content

Instantly share code, notes, and snippets.

@ryansgot
Last active October 17, 2018 14:03
Show Gist options
  • Save ryansgot/e8b4ee4764a37e69ce859c3ab0d9a17a to your computer and use it in GitHub Desktop.
Save ryansgot/e8b4ee4764a37e69ce859c3ab0d9a17a to your computer and use it in GitHub Desktop.
ForSureDB CRUD for the Impatient (Java)
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