Mercury-IM/persistence-room/src/main/java/org/mercury_im/messenger/persistence/room/dao/AccountDao.java

50 lines
1.5 KiB
Java

package org.mercury_im.messenger.persistence.room.dao;
import androidx.lifecycle.LiveData;
import androidx.annotation.WorkerThread;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.TypeConverters;
import androidx.room.Update;
import org.jxmpp.jid.EntityBareJid;
import org.mercury_im.messenger.persistence.model.AccountModel;
import org.mercury_im.messenger.persistence.room.model.RoomAccountModel;
import org.mercury_im.messenger.persistence.room.type_converter.EntityBareJidConverter;
import java.util.List;
@Dao
@TypeConverters(EntityBareJidConverter.class)
@WorkerThread
public interface AccountDao extends BaseDao<RoomAccountModel> {
/**
* Return a {@link LiveData} wrapping a {@link List} which contains all
* {@link RoomAccountModel Accounts} which are currently stored in the database.
*
* @return live updating account list
*/
@Query("select * from accounts")
LiveData<List<RoomAccountModel>> getAllAccountsLive();
@Query("select * from accounts")
List<RoomAccountModel> getAllAccounts();
/**
* Return the {@link RoomAccountModel Account} which is identified by the given id.
*
* @param id id of the account
* @return account or null
*/
@Query("select * from accounts where id = :id")
LiveData<RoomAccountModel> getAccountById(long id);
@Query("select * from accounts where jid = :jid")
LiveData<RoomAccountModel> getAccountByJid(EntityBareJid jid);
}