-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observe query #1470
Merged
Merged
Observe query #1470
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adding observe query api to datastore plugin. Work in progress.
…ring based on query predicate.
…from configuration.
...e/src/androidTest/java/com/amplifyframework/datastore/storage/SynchronousStorageAdapter.java
Outdated
Show resolved
Hide resolved
...e/src/androidTest/java/com/amplifyframework/datastore/storage/SynchronousStorageAdapter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/amplifyframework/datastore/DataStoreQuerySnapshot.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/amplifyframework/datastore/DataStorePlugin.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/amplifyframework/datastore/DataStoreCategoryBehavior.java
Show resolved
Hide resolved
...tastore/src/main/java/com/amplifyframework/datastore/storage/sqlite/ObserveQueryManager.java
Outdated
Show resolved
Hide resolved
aws-datastore/src/main/java/com/amplifyframework/datastore/storage/sqlite/ModelSorter.java
Outdated
Show resolved
Hide resolved
...java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapterObserveQueryTest.java
Outdated
Show resolved
Hide resolved
…only include complete list of items and query options don't have pagination.
rjuliano
approved these changes
Sep 29, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments, but it LGTM!
aws-datastore/src/main/java/com/amplifyframework/datastore/storage/sqlite/ModelComparator.java
Outdated
Show resolved
Hide resolved
...t/java/com/amplifyframework/datastore/storage/sqlite/ModelUpgradeSQLiteInstrumentedTest.java
Outdated
Show resolved
Hide resolved
...t/java/com/amplifyframework/datastore/storage/sqlite/ModelUpgradeSQLiteInstrumentedTest.java
Outdated
Show resolved
Hide resolved
aws-datastore/src/test/java/com/amplifyframework/datastore/storage/sqlite/ModelSorterTest.java
Show resolved
Hide resolved
# Conflicts: # aws-datastore/src/androidTest/java/com/amplifyframework/datastore/storage/sqlite/ModelUpgradeSQLiteInstrumentedTest.java # aws-datastore/src/main/java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapter.java # settings.gradle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
Return a stream that emits a snapshot with the initial data in the local DB, and subsequent snapshots containing data (items) synced from the cloud and isSynced status
Allow for processing updates in batches
Sample Kotlin code:
private fun observeQuery() {
val tag = "ObserveQuery"
val onQuerySnapshot: Consumer<DataStoreQuerySnapshot> =
Consumer<DataStoreQuerySnapshot> { value: DataStoreQuerySnapshot ->
Log.d(tag, "success on snapshot")
Log.d(tag, "num records: " + value.items.size)
Log.d(tag, "sync status: " + value.isSynced)
}
val observationStarted =
Consumer { _: Cancelable ->
Log.d(tag, "success on cancelable")
}
val onObservationError =
Consumer { value: DataStoreException ->
Log.d(tag, "error on snapshot$value")
}
val onObservationComplete = Action {
Log.d(tag, "complete")
}
val predicate: QueryPredicate =
NAME.contains("1").or(NAME.contains("2")).or(NAME.contains("3"))
val QuerySortBy = QuerySortBy("car", "name", QuerySortOrder.ASCENDING)
val options = ObserveQueryOptions(predicate, listOf(QuerySortBy))
Amplify.DataStore.observeQuery(
Blog::class.java,
options,
observationStarted,
onQuerySnapshot,
onObservationError,
onObservationComplete
)
}
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.