package net.ktnx.mobileledger.dao;
+import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
@Dao
public interface TemplateAccountDAO {
@Insert
- Long insert(TemplateAccount item);
+ Long insertSync(TemplateAccount item);
@Update
- void update(TemplateAccount... items);
+ void updateSync(TemplateAccount... items);
@Delete
- void delete(TemplateAccount item);
+ void deleteSync(TemplateAccount item);
@Query("SELECT * FROM template_accounts WHERE template_id=:template_id")
LiveData<List<TemplateAccount>> getTemplateAccounts(Long template_id);
@Query("SELECT * FROM template_accounts WHERE id = :id")
LiveData<TemplateAccount> getPatternAccountById(Long id);
-// not useful for now
-// @Transaction
-// @Query("SELECT * FROM patterns")
-// List<PatternWithAccounts> getPatternsWithAccounts();
+ @Query("UPDATE template_accounts set position=-1 WHERE template_id=:templateId")
+ void prepareForSave(@NonNull Long templateId);
+
+ @Query("DELETE FROM template_accounts WHERE position=-1 AND template_id=:templateId")
+ void finishSave(@NonNull Long templateId);
}