AndroidApp/TurbineDao.java

24 lines
838 B
Java

package com.example.myapplication.DataBase;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import com.example.myapplication.model.Turbine;
import java.util.List;
@Dao
public interface TurbineDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<Turbine> turbines);
@Query("SELECT * FROM turbines WHERE projectId = :projectId")
List<Turbine> getTurbinesByProject(String projectId);
@Query("DELETE FROM turbines WHERE projectId = :projectId")
void deleteByProjectId(String projectId);
@Query("SELECT * FROM turbines WHERE projectId = :projectId AND " +
"(turbineId LIKE :query OR turbineName LIKE :query)")
List<Turbine> searchTurbines(String projectId, String query);
}