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
SaveResult<Uri> result = Forsuredb.myTable() // <-- the generated ForSure class serves as your entrypoint | |
.set() // <-- enter insert/update/delete portion of query | |
.stringColumn("My String") // <-- set the value of the column | |
.intColumn(42) // <-- column value setters are typesafe | |
.save(); // <-- performs the insertion and sends back a SaveResult | |
Uri inserted = result.inserted(); // <-- SaveResult contains a locator for the inserted record |
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
MyTable myTableApi = ForSure.myTable().getApi(); // <-- get retrieval API that Forsuredb generated for you | |
Retriever r = ForSure.myTable() // <-- the generated ForSure class serves as your entrypoint | |
.find() // <-- start narrowing the number of records and columns to return | |
.byIntColumnBetween(3).andInclusive(10) // <-- set bounds (3, 10] | |
.and().byNotDeleted() // <-- add additional condition that the record must not be "soft deleted" | |
.then() // <-- end narrowing number of records and columns to return | |
.get(); // <-- execute the query and return a Retriever (a Cursor/ResultSet) | |
if (r.moveToFirst()) { // <-- Retrievers get iterated just like Cursors or ResultSets | |
do { | |
String stringColumn = myTableApi.stringColumn(r); |
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
SaveResult<Uri> result = ForSure.myTable() | |
.find() // <-- start narrowing the number of records and columns to update | |
.byIntColumnBetween(3).andInclusive(10) // <-- set bounds (3, 10] | |
.and().byNotDeleted() // <-- add additional condition that the record must not be "soft deleted" | |
.then() // <-- end narrowing number of records and columns to return | |
.set() // <-- start setting column values to update | |
.stringColumn("Your int_column value is greater than three and less than or equal to 10") | |
.save(); | |
System.out.println("Number of records updated: " + result.rowsAffected()); |
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
int rowsAffected = ForSure.myTable() // <-- the generated ForSure class serves as your entrypoint | |
.find() // <-- start narrowing the number of records and columns to update | |
.byIntColumnBetween(3).andInclusive(10) // <-- set bounds (3, 10] | |
.and().byNotDeleted() // <-- add additional condition that the record must not be "soft deleted" | |
.then() // <-- end narrowing number of records and columns to return | |
.set() // <-- enter insert/update/delete section | |
.hardDelete(); // <-- perform a hard deletion--actually deleting the record | |
System.out.println("Number of records deleted: " + rowsAffected); |
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
forsuredb { | |
applicationPackageName = 'com.fsryan.forsuredb.example' | |
resultParameter = "com.fsryan.forsuredb.queryable.DirectLocator" | |
recordContainer = "com.fsryan.forsuredb.queryable.FSContentValues" | |
migrationDirectory = 'app/src/main/assets' | |
appProjectDirectory = 'app' | |
resourcesDirectory = 'app/src/main/resources' | |
fsSerializerFactoryClass = 'com.fsryan.forsuredb.example.JsonAdapterFactory' | |
dbmsIntegratorClass = 'com.fsryan.forsuredb.sqlitelib.SqlGenerator' | |
} |
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
$ ./gradlew :app:dbMigrate |
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
// Android | |
dependencies { | |
/* ... */ | |
annotationProcessor "com.fsryan.forsuredb:forsuredbcompiler:$forsuredbversion" | |
/* ... */ | |
} |
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
apply plugin: /*'com.android.application', 'com.android.library', or 'java'*/ | |
apply plugin: 'com.fsryan.gradle.forsuredb' | |
forsuredb { | |
/*...*/ | |
} |
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
package com.fsryan.forsuredb.example.data.db; | |
import com.fsryan.forsuredb.annotations.FSColumn; | |
import com.fsryan.forsuredb.annotations.FSDefault; | |
import com.fsryan.forsuredb.annotations.FSForeignKey; | |
import com.fsryan.forsuredb.annotations.FSTable; | |
import com.fsryan.forsuredb.annotations.Unique; | |
import com.fsryan.forsuredb.api.FSGetApi; | |
import com.fsryan.forsuredb.api.Retriever; |
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
Retriever r = ForSure.employeesTable() | |
.find().byNotDeleted() | |
.and().byFirstName("FSRyan") | |
.and().byLastName("Developer") | |
.then() | |
.get(); |
OlderNewer