From 00a141a10150390c6d721eb374d0236c4c519de2 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 14 Jan 2024 13:23:48 +0900 Subject: [PATCH] =?UTF-8?q?VcsRevDao=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/database/dao/VcsRevDao.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) 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が必要か検討 + }