Last active
May 21, 2018 14:07
-
-
Save ryansgot/2fb506251da5b4fe2dcd9f74df47d193 to your computer and use it in GitHub Desktop.
Example Forsure DB Table Definition
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; | |
@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