Proyectos de Subversion Android Microlearning

Rev

Autoría | Ultima modificación | Ver Log |

package com.cesams.twogetskills.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.cesams.twogetskills.entity.Capsule;
import com.cesams.twogetskills.room.ResultCount;

import java.util.List;

@Dao
public interface CapsuleDao {

    @Query("SELECT * FROM tb_capsules ORDER BY position, name")
    public List<Capsule> selectAll();

    @Query("SELECT * FROM tb_capsules WHERE topic_uuid = :topicUuid ORDER BY position, name")
    public List<Capsule> selectAllByTopicUuid(String topicUuid);


    @Query("SELECT * FROM tb_capsules WHERE uuid = :uuid LIMIT 1")
    Capsule selectByUuid(String uuid);

    @Query("SELECT COUNT(*) AS count FROM tb_capsules WHERE topic_uuid = :topicUuid LIMIT 1")
    ResultCount getCountByTopicUuid(String topicUuid);

    @Query("SELECT COUNT(*) AS count FROM tb_capsules LIMIT 1")
    ResultCount getCount();

    @Insert
    void insert(Capsule capsule);


    @Update
    void update(Capsule capsule);

    @Query("DELETE FROM tb_capsules WHERE uuid = :uuid")
    void removeByUuid(String uuid);

    @Query("DELETE FROM tb_capsules")
    void removeAll();

}