diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java index c6ce2169..3213ca28 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java @@ -1,7 +1,44 @@ package one.nem.lacerta.source.database.dao; import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; + +import java.util.List; + +import one.nem.lacerta.source.database.entity.VcsRevEntity; @Dao public interface VcsRevDao { + + // Select + @Query("SELECT * FROM vcs_rev WHERE id = :id") + VcsRevEntity findById(String id); + + @Query("SELECT * FROM vcs_rev") + List findAll(); + + @Query("SELECT * FROM vcs_rev WHERE id IN (:ids)") + List findByIds(List ids); + + @Query("SELECT * FROM vcs_rev WHERE document_id = :documentId") + List findByDocumentId(String documentId); + + @Query("SELECT * FROM vcs_rev WHERE document_id = :documentId ORDER BY created_at DESC LIMIT 1") + VcsRevEntity findLatestByDocumentId(String documentId); + + @Query("SELECT * FROM vcs_rev WHERE document_id = :documentId AND branch_name = :branchName ORDER BY created_at DESC LIMIT 1") + VcsRevEntity findLatestByDocumentIdAndBranchName(String documentId, String branchName); + + @Insert + void insertAll(VcsRevEntity... vcsRevs); + + @Insert + void insertAll(List vcsRevs); + + @Insert + void insert(VcsRevEntity vcsRev); + + // TODO-rca: Update, Deleteが必要か検討 + }