53 lines
1.5 KiB
Java
53 lines
1.5 KiB
Java
package org.mercury_im.messenger.persistence.database.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.database.model.AccountModel;
|
|
import org.mercury_im.messenger.persistence.database.type_converter.EntityBareJidConverter;
|
|
|
|
import java.util.List;
|
|
|
|
@Dao
|
|
@TypeConverters(EntityBareJidConverter.class)
|
|
@WorkerThread
|
|
public interface AccountDao {
|
|
|
|
/**
|
|
* Return a {@link LiveData} wrapping a {@link List} which contains all
|
|
* {@link AccountModel Accounts} which are currently stored in the database.
|
|
*
|
|
* @return live updating account list
|
|
*/
|
|
@Query("select * from AccountModel")
|
|
LiveData<List<AccountModel>> getAllAccounts();
|
|
|
|
/**
|
|
* Return the {@link AccountModel Account} which is identified by the given id.
|
|
*
|
|
* @param id id of the account
|
|
* @return account or null
|
|
*/
|
|
@Query("select * from AccountModel where id = :id")
|
|
LiveData<AccountModel> getAccountById(long id);
|
|
|
|
@Query("select * from AccountModel where jid = :jid")
|
|
LiveData<AccountModel> getAccountByJid(EntityBareJid jid);
|
|
|
|
@Insert
|
|
long insertAccount(AccountModel account);
|
|
|
|
@Update
|
|
void updateAccount(AccountModel account);
|
|
|
|
@Delete
|
|
void deleteAccount(AccountModel account);
|
|
}
|