Skip to content

Instantly share code, notes, and snippets.

@ryansgot
Last active May 21, 2018 14:07
Show Gist options
  • Save ryansgot/2fb506251da5b4fe2dcd9f74df47d193 to your computer and use it in GitHub Desktop.
Save ryansgot/2fb506251da5b4fe2dcd9f74df47d193 to your computer and use it in GitHub Desktop.
Example Forsure DB Table Definition
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;
@FSTable("employees")
public interface EmployeesTable extends FSGetApi {
@FSColumn("uuid") @Unique(index = true) String uuid(Retriever retriever);
@FSColumn("first_name") String firstName(Retriever retriever);
@FSColumn("last_name") String lastName(Retriever retriever);
@FSDefault("1")
@FSForeignKey(
apiClass = PositionsTable.class, // <-- allows for code generation of resolver to account for join
columnName = "_id", // <-- _id is a built-in primary key (unless you use a composite primary key)
updateAction = "CASCADE", // <-- what to do when the _id column is updated
deleteAction = "SET DEFAULT" // <-- what to do when the record pointed to is deleted
)
long positionId(Retriever retriever);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment