Created
April 25, 2019 09:39
-
-
Save sergiocasero/aa59f7a369d917e648be01ea3bb69cc2 to your computer and use it in GitHub Desktop.
DaoGenerator code template for IntelliJ/AS
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 ${PACKAGE_NAME} | |
#parse("File Header.java") | |
import androidx.room.Dao | |
import androidx.room.Insert | |
import androidx.room.Update | |
import androidx.room.Query | |
@Dao | |
interface ${NAME} { | |
@Insert | |
suspend fun insert(${tableName}s: List<${tableClass}>) | |
@Insert | |
suspend fun insert($tableName: ${tableClass}) | |
@Query("SELECT * FROM $tableName") | |
suspend fun getAll(): List<${tableClass}> | |
@Query("SELECT * FROM $tableName WHERE ${idFieldName} = :id") | |
suspend fun get(id: ${idFieldType}): ${tableClass} | |
@Update | |
suspend fun update(${tableName}: ${tableClass}) | |
@Query("DELETE from ${tableName}") | |
suspend fun deleteAll() | |
@Query("DELETE FROM $tableName WHERE ${idFieldName} = :id") | |
suspend fun delete(id: ${idFieldType}): ${tableClass} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment