I have multiple datasource in my application (mysql and mongodb) and i am using JpaRepository (spring data jpa) and MongoRepository (spring data mongo ) respectively.
The below code works for getting all the imei numbers from the vehicle table(mysql)
@Repository
public interface VehicleRepo extends JpaRepository<Vehicle, Long>{
@Query(value = "SELECT imei FROM vehicle", nativeQuery = true)
public List<Object[]> findImei();
}
I have another mongo repo like below.
@Repository
public interface DeviceRepo extends MongoRepository<Device, String>{
// looking for a method which returns all the distinct imei
}
I want to know what what would be the query in mongodb.
(My requirement is to select all the only distinct imei field from the Device and only single field selection like VehicleRepo)
I have tried multiple combinations but none worked.