Skip to content

Commit

Permalink
fixed delete use case, query returns a list of results
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyad-37 committed Nov 19, 2018
1 parent 7fb31a5 commit 53e80a0
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 404 deletions.
4 changes: 2 additions & 2 deletions usecases/src/main/java/com/zeyad/usecases/api/DataService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ internal class DataService(private val mDataStoreFactory: DataStoreFactory,
}
}

override fun <M> queryDisk(query: String, clazz: Class<M>): Single<M> {
val result: Single<M> = try {
override fun <M> queryDisk(query: String, clazz: Class<M>): Single<List<M>> {
val result: Single<List<M>> = try {
mDataStoreFactory.disk(Any::class.java).queryDisk(query, clazz)
.compose(ReplayingShare.instance()).singleOrError()
} catch (e: IllegalAccessException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ interface IDataService {
* @param realmQueryProvider query tp select list of item(s).
* @return
*/
fun <M> queryDisk(query: String, clazz: Class<M>): Single<M>
fun <M> queryDisk(query: String, clazz: Class<M>): Single<List<M>>

/**
* Creates a repository pattern with live objects
Expand Down
2 changes: 1 addition & 1 deletion usecases/src/main/java/com/zeyad/usecases/db/BaseDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface BaseDao<E> {
fun getAllItems(query: SupportSQLiteQuery): Single<List<E>>

@RawQuery
fun getQuery(query: SupportSQLiteQuery): Single<E>
fun getQuery(query: SupportSQLiteQuery): Single<List<E>>

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertItemsReplace(vararg objects: E): List<Long>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface DataBaseManager {
*
* @param query The query used to look for inside the DB.
*/
fun <E> getQuery(query: String, clazz: Class<E>): Flowable<E>
fun <E> getQuery(query: String, clazz: Class<E>): Flowable<List<E>>

/**
* Puts and element into the DB.
Expand Down Expand Up @@ -70,23 +70,23 @@ interface DataBaseManager {
*
* @param clazz Class type of the items to be deleted.
*/
fun <E> evictAll(clazz: Class<E>): Single<Any>
fun <E> evictAll(clazz: Class<E>): Single<Boolean>

/**
* Evict a collection elements of the DB.
*
* @param list List to be deleted.
* @param clazz Class type of the items to be deleted.
*/
fun <E> evictCollection(list: List<E>, clazz: Class<E>): Single<Any>
fun <E> evictCollection(list: List<E>, clazz: Class<E>): Single<Boolean>

/**
* Evict a collection elements of the DB.
*
* @param list List of ids to be deleted.
* @param clazz Class type of the items to be deleted.
*/
fun <E> evictCollectionById(list: List<Any>, clazz: Class<E>, idFieldName: String): Single<Any>
fun <E> evictCollectionById(list: List<Any>, clazz: Class<E>, idFieldName: String): Single<Boolean>

/**
* Evict element by id of the DB.
Expand Down
328 changes: 0 additions & 328 deletions usecases/src/main/java/com/zeyad/usecases/db/RealmManager.java

This file was deleted.

Loading

0 comments on commit 53e80a0

Please sign in to comment.