class DittoPendingCursorOperation
These objects are returned when using find
-like functionality on DittoCollections. They allow chaining
of further query-related functions to do things like add a limit to the number of documents you want
returned or specify how you want the documents to be sorted and ordered. You can either call exec
on the
object to get an array of DittoDocuments as an immediate return value, or you can establish either a
live query or a subscription, which both work over time. A live query, established by calling observe
,
will notify you every time there's an update to a document that matches the query you provided in the
preceding find
-like call. A subscription, established by calling subscribe
, will act as a signal to
other peers that the device connects to that you would like to receive updates from them about documents
that match the query you provided in the preceding find
-like call. Calling observe
will generate both a
subscription and a live query at the same time. If you'd like to only observe local changes then you can call
observeLocal
. Update and remove functionality is also exposed through this object.
val collectionName: String
the name of the collection that the operation will be performed on. |
|
var limit: Int |
|
var offset: Int |
|
var orderDefinitions: MutableList<Ditto_OrderDefinition> |
|
val query: String
the query that will be used when performing the operation. |
fun evict(): List<String>
Evict all documents that match the query generated by the preceding function chaining. |
|
fun exec(): List<DittoDocument>
Execute the query generated by the preceding function chaining and return the list of matching documents. |
|
fun limit(limit: Int): DittoPendingCursorOperation
Limit the number of documents that get returned when querying a collection for matching documents. |
|
fun observe(eventHandler: (List<DittoDocument>, DittoLiveQueryEvent) -> Unit): DittoLiveQuery
Enables you to listen for changes that occur on a collection. The fun observe(callback: DittoLiveQueryCallback): DittoLiveQuery
Enables you to listen for changes that occur on a collection. The |
|
fun observeLocal(eventHandler: (List<DittoDocument>, DittoLiveQueryEvent) -> Unit): DittoLiveQuery fun observeLocal(callback: DittoLiveQueryCallback): DittoLiveQuery
Enables you to listen for changes that occur on a collection. This won't subscribe to receive changes
made remotely by others and so it will only fire updates when a local change is made. If you want to
receive remotely performed updates as well then use |
|
fun offset(offset: Int): DittoPendingCursorOperation
Offset the resulting set of matching documents. This is useful if you aren't interested in the first
N matching documents for one reason or another. For example, you might already have queried the
collection and obtained the first 20 matching documents and so you might want to run the same query as
you did previously but ignore the first 20 matching documents, and that is where you would use
|
|
fun remove(): List<String>
Remove all documents that match the query generated by the preceding function chaining. |
|
fun sort(query: String, direction: DittoSortDirection): DittoPendingCursorOperation
Sort the documents that match the query provided in the preceding |
|
fun subscribe(): DittoSubscription
Enables you to subscribe to changes that occur on a collection. Having a subscription acts as a signal
to others that you are interested in receiving updates when local or remote changes are made to
documents that match the query generated by the chain of operations that precedes the call to
|
|
fun update(closure: (List<DittoMutableDocument>) -> Unit): Map<String, List<DittoUpdateResult>> fun update(updater: DittoMutableDocumentsUpdater): Map<String, List<DittoUpdateResult>>
Update documents that match the query generated by the preceding function chaining. |