DittoSyncKit  1.0.0-alpha1
Public Member Functions | List of all members
Ditto.SyncKit.DittoPendingCursorOperation Class Reference

These objects are returned when using find-like functionality on DittoCollection objects. More...

Public Member Functions

DittoPendingCursorOperation Limit (int limit)
 Limit the number of documents that get returned when querying a collection for matching documents. More...
 
DittoPendingCursorOperation Offset (uint offset)
 Offset the resulting set of matching documents. More...
 
DittoPendingCursorOperation Sort (string query, DittoSortDirection direction)
 Sort the documents that match the query provided in the preceding find-like function call. More...
 
unsafe List< DittoDocumentExec ()
 Execute the query generated by the preceding function chaining and return the list of matching documents. More...
 
unsafe Dictionary< string, List< DittoUpdateResult > > Update (Action< List< DittoMutableDocument >> updater)
 Update documents that match the query generated by the preceding function chaining. More...
 
unsafe List< string > Remove ()
 Remove all documents that match the query generated by the preceding function chaining. More...
 
unsafe List< string > Evict ()
 Evict all documents that match the query generated by the preceding function chaining. More...
 
DittoSubscription Subscribe ()
 Enables you to subscribe to changes that occur in a collection remotely. More...
 
DittoLiveQuery Observe (Action< List< DittoDocument >, DittoLiveQueryEvent > handler)
 Enables you to subscribe to changes that occur in a collection locally and remotely. The handler Action will be called when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to Observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided handler to be called when an update occurs. More...
 
DittoLiveQuery ObserveLocal (Action< List< DittoDocument >, DittoLiveQueryEvent > handler)
 Enables you to subscribe to changes that occur in a collection locally. More...
 

Detailed Description

These objects are returned when using find-like functionality on DittoCollection objects.

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 DittoDocument objects 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(Action<List<DittoDocument>, DittoLiveQueryEvent>), 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(Action<List<DittoDocument>, DittoLiveQueryEvent>).

Update, remove, and evict functionality is also exposed through this object.

Member Function Documentation

◆ Evict()

unsafe List<string> Ditto.SyncKit.DittoPendingCursorOperation.Evict ( )
inline

Evict all documents that match the query generated by the preceding function chaining.

Returns
A list containing the IDs of the documents that were evicted.

◆ Exec()

unsafe List<DittoDocument> Ditto.SyncKit.DittoPendingCursorOperation.Exec ( )
inline

Execute the query generated by the preceding function chaining and return the list of matching documents.

Returns
A list of DittoDocument objects matching the query generated by the preceding function chaining.

◆ Limit()

DittoPendingCursorOperation Ditto.SyncKit.DittoPendingCursorOperation.Limit ( int  limit)
inline

Limit the number of documents that get returned when querying a collection for matching documents.

Parameters
limitThe maximum number of documents that will be returned.
Returns
A DittoPendingCursorOperation that you can chain further function calls and then use to either get the matching documents immediately or get updates about them over time.

◆ Observe()

DittoLiveQuery Ditto.SyncKit.DittoPendingCursorOperation.Observe ( Action< List< DittoDocument >, DittoLiveQueryEvent handler)
inline

Enables you to subscribe to changes that occur in a collection locally and remotely. The handler Action will be called when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to Observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided handler to be called when an update occurs.

Parameters
handlerAn Action that will be called every time there is a transaction committed to the store that involves modifications to documents matching the query in the collection that Observe was called on.
Returns
A DittoLiveQuery object that must be kept in scope for as long as you want to keep receiving updates.

◆ ObserveLocal()

DittoLiveQuery Ditto.SyncKit.DittoPendingCursorOperation.ObserveLocal ( Action< List< DittoDocument >, DittoLiveQueryEvent handler)
inline

Enables you to subscribe to changes that occur in a collection locally.

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 Observe(Action<List<DittoDocument>, DittoLiveQueryEvent>) or call Subscribe with the relevant query. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided handler to be called when an update occurs.

Parameters
handlerAn Action that will be called every time there is a transaction committed to the store that involves modifications to documents matching the query in the collection that ObserveLocal was called on.
Returns
A DittoLiveQuery object that must be kept in scope for as long as you want to keep receiving updates.

◆ Offset()

DittoPendingCursorOperation Ditto.SyncKit.DittoPendingCursorOperation.Offset ( uint  offset)
inline

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 when you would use Offset(uint).

Parameters
offsetThe number of matching documents that you want the eventual resulting set of matching documents to be offset by (and thus not include).
Returns
A DittoPendingCursorOperation that you can chain further function calls and then use to either get the matching documents immediately or get updates about them over time.

◆ Remove()

unsafe List<string> Ditto.SyncKit.DittoPendingCursorOperation.Remove ( )
inline

Remove all documents that match the query generated by the preceding function chaining.

Returns
A list containing the IDs of the documents that were removed.

◆ Sort()

DittoPendingCursorOperation Ditto.SyncKit.DittoPendingCursorOperation.Sort ( string  query,
DittoSortDirection  direction 
)
inline

Sort the documents that match the query provided in the preceding find-like function call.

Parameters
queryThe query specifies the logic to be used when sorting the matching documents.
directionSpecify whether you want the sorting order to be ascending or descending.
Returns
A DittoPendingCursorOperation that you can chain further function calls and then use to either get the matching documents immediately or get updates about them over time.

◆ Subscribe()

DittoSubscription Ditto.SyncKit.DittoPendingCursorOperation.Subscribe ( )
inline

Enables you to subscribe to changes that occur in a collection remotely.

Having a subscription acts as a signal to other peers 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 Subscribe. The returned DittoSubscription object must be kept in scope for as long as you want to keep receiving updates.

Returns
A DittoSubscription object that must be kept in scope for as long as you want to keep receiving updates for documents that match the query specified in the preceding chain.

◆ Update()

unsafe Dictionary<string, List<DittoUpdateResult> > Ditto.SyncKit.DittoPendingCursorOperation.Update ( Action< List< DittoMutableDocument >>  updater)
inline

Update documents that match the query generated by the preceding function chaining.

Parameters
updaterA block that gets called with all of the documents matching the query. The documents are DittoMutableDocument objects so you can call update-related functions on them.
Returns
A dictionary mapping document IDs to lists of DittoUpdateResult that describes the updates that were performed for each document.