Ditto 4.5.0
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
DittoSDK.DittoStore Class Reference

A class encompassing functionality relating to the embedded storage. This is not a class you instantiate directly. Instead you access DittoStore objects using Ditto.Store. More...

Public Member Functions

DittoPendingCollectionsOperation Collections ()
 Returns an object that lets you fetch or observe the collections in the store.
 
DittoCollection Collection (string collectionName)
 A method to reference a DittoCollection.
 
unsafe List< DittoWriteTransactionResultWrite (Action< DittoWriteTransaction > handler)
 Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.
 
Task< DittoQueryResultExecuteAsync (string query, Dictionary< string, object > arguments=default)
 Executes a DQL query and returns matching items as a query result.
 
DittoStoreObserver RegisterObserver (string query, Action< DittoQueryResult > storeObservationHandler)
 
DittoStoreObserver RegisterObserver (string query, Action< DittoQueryResult, Action > storeObservationHandlerWithSignalNext)
 
DittoStoreObserver RegisterObserver (string query, Func< DittoQueryResult, Task > storeObservationHandlerTask)
 
DittoStoreObserver RegisterObserver (string query, Dictionary< string, object > arguments, Func< DittoQueryResult, Task > storeObservationHandlerTask)
 
DittoStoreObserver RegisterObserver (string query, Dictionary< string, object > arguments, Action< DittoQueryResult > storeObservationHandler)
 
DittoStoreObserver RegisterObserver (string query, Dictionary< string, object > arguments, Action< DittoQueryResult, Action > storeObservationHandlerWithSignalNext)
 Installs and returns a store observer for a query, configuring Ditto to trigger the passed in change handler whenever documents in the local passed in query must be a SELECT query, otherwise a store error with queryNotSupported reason is thrown.
 

Properties

IReadOnlyCollection< DittoStoreObserverObservers [get]
 Gets all currently active store observers.
 
unsafe List< string > CollectionNames [get]
 Gets the names of all collections known about on this device.
 
DittoDiskUsage DiskUsage [get]
 Gets a reference to the store disk usage.
 
DittoCollection this[string collectionName] = new ConcurrentDictionary<DittoStoreObserver, byte>() [get]
 Retrieve a DittoCollection. var collection = ditto.store["cars"];
 

Detailed Description

A class encompassing functionality relating to the embedded storage. This is not a class you instantiate directly. Instead you access DittoStore objects using Ditto.Store.

Member Function Documentation

◆ Collection()

DittoCollection DittoSDK.DittoStore.Collection ( string  collectionName)
inline

A method to reference a DittoCollection.

Parameters
collectionNameThe name of the collection.
Returns
A reference to the DittoCollection.

◆ Collections()

DittoPendingCollectionsOperation DittoSDK.DittoStore.Collections ( )
inline

Returns an object that lets you fetch or observe the collections in the store.

Returns
An object that lets you fetch or observe the collections in the store.

◆ ExecuteAsync()

Task< DittoQueryResult > DittoSDK.DittoStore.ExecuteAsync ( string  query,
Dictionary< string, object >  arguments = default 
)
inline

Executes a DQL query and returns matching items as a query result.

Returns
A DittoQueryResult containing a DittoQueryResultItem for each match.
Parameters
queryA string containing a valid query expressed in DQL.
argumentsA dictionary of values keyed by the placeholder name without the leading :.
Example:
new Dictionary<string, object>()
{
{ "mileage", 123 }
}
Exceptions
DittoStoreExceptionCan throw a DittoStoreException. For more granular exception handling check its subtypes:
  • DittoQueryArgumentsInvalidException - If the query string is not a valid DQL
  • DittoQueryInvalidException - If the arguments dictionary is not valid (contains unsupported types)
  • DittoQueryException - Error during query execution.

◆ RegisterObserver() [1/6]

DittoStoreObserver DittoSDK.DittoStore.RegisterObserver ( string  query,
Action< DittoQueryResult storeObservationHandler 
)
inline
See also
RegisterObserver(string, Dictionary<string, object>, Action<DittoQueryResult, Action>)

◆ RegisterObserver() [2/6]

DittoStoreObserver DittoSDK.DittoStore.RegisterObserver ( string  query,
Action< DittoQueryResult, Action >  storeObservationHandlerWithSignalNext 
)
inline
See also
RegisterObserver(string, Dictionary<string, object>, Action<DittoQueryResult, Action>)

◆ RegisterObserver() [3/6]

DittoStoreObserver DittoSDK.DittoStore.RegisterObserver ( string  query,
Dictionary< string, object >  arguments,
Action< DittoQueryResult storeObservationHandler 
)
inline
See also
RegisterObserver(string, Dictionary<string, object>, Action<DittoQueryResult, Action>)
Parameters
storeObservationHandlerA simplified callback containing the DittoQueryResult, where signalNext is automatically called when the handler finishes.

◆ RegisterObserver() [4/6]

DittoStoreObserver DittoSDK.DittoStore.RegisterObserver ( string  query,
Dictionary< string, object >  arguments,
Action< DittoQueryResult, Action >  storeObservationHandlerWithSignalNext 
)
inline

Installs and returns a store observer for a query, configuring Ditto to trigger the passed in change handler whenever documents in the local passed in query must be a SELECT query, otherwise a store error with queryNotSupported reason is thrown.

Returns
An active DittoStoreObserver for the passed in query and arguments. You'll have to keep it to be able to cancel the observation, i.e. remove it from the store again. Otherwise it will remain active until Ditto goes out of scope.
Parameters
queryA string containing a valid query expressed in DQL.
argumentsA dictionary of values keyed by the placeholder name without the leading :
Example:
new Dictionary<string, object>() { { "mileage" , 123 } }
storeObservationHandlerWithSignalNextA callback that is invoked whenever an active store observer receives a new result.
The first parameter is the query result, while the second is an Action, signalNext, that should be called when the handler is ready to receive new data.
Exceptions
DittoStoreExceptionCan throw a DittoStoreException. For more granular exception handling check the following subtypes:
  • DittoQueryArgumentsInvalidException - If the query string is not a valid DQL.
  • DittoQueryInvalidException - If the arguments dictionary is not valid (contains unsupported types).
  • DittoQueryNotSupportedException - If the query is not a SELECT query.

◆ RegisterObserver() [5/6]

DittoStoreObserver DittoSDK.DittoStore.RegisterObserver ( string  query,
Dictionary< string, object >  arguments,
Func< DittoQueryResult, Task >  storeObservationHandlerTask 
)
inline
See also
RegisterObserver(string, Dictionary<string, object>, Action<DittoQueryResult, Action>)
Parameters
storeObservationHandlerTaskA simplified callback containing the DittoQueryResult, to be used in an async context, where signalNext is automatically called when the handler task finishes.

◆ RegisterObserver() [6/6]

DittoStoreObserver DittoSDK.DittoStore.RegisterObserver ( string  query,
Func< DittoQueryResult, Task >  storeObservationHandlerTask 
)
inline
See also
RegisterObserver(string, Dictionary<string, object>, Func<DittoQueryResult, Task>)

◆ Write()

unsafe List< DittoWriteTransactionResult > DittoSDK.DittoStore.Write ( Action< DittoWriteTransaction handler)
inline

Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.

Parameters
handlerAn Action that provides access to a write transaction object that can be used to perform operations on the store.
Returns
A list ofDittoWriteTransactionResult objects. There is a result for each operation performed as part of the write transaction.

Property Documentation

◆ CollectionNames

unsafe List<string> DittoSDK.DittoStore.CollectionNames
get

Gets the names of all collections known about on this device.

Note, this will return immediately what is in the store.

◆ this[string collectionName]

DittoCollection DittoSDK.DittoStore.this[string collectionName] = new ConcurrentDictionary<DittoStoreObserver, byte>()
get

Retrieve a DittoCollection. var collection = ditto.store["cars"];

Parameters
collectionNameThe name of the collection.

A collection name is valid if:

  • its length is less than 100
  • it is not empty
  • it does not contain the char '\0'
  • it does not begin with "$TS_"
    Returns
    A reference to the DittoCollection.