Ditto 4.7.2
|
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< DittoWriteTransactionResult > | Write (Action< DittoWriteTransaction > handler) |
Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections. | |
Task< DittoQueryResult > | ExecuteAsync (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. | |
Task< DittoAttachment > | NewAttachmentAsync (string path, Dictionary< string, string > metadata=null) |
Creates a new attachment, which can then be inserted into a document. | |
DittoAttachmentFetcher | FetchAttachment (DittoAttachmentToken token, Action< DittoAttachmentFetchEvent > onFetchEvent) |
Fetch the attachment corresponding to the provided attachment token. | |
DittoAttachmentFetcher | FetchAttachment (Dictionary< string, object > token, Action< DittoAttachmentFetchEvent > onFetchEvent) |
Fetch the attachment corresponding to the provided attachment token. Expects a dictionary representation of the token as returned in a DittoQueryResultItem | |
Properties | |
IReadOnlyCollection< DittoStoreObserver > | Observers [get] |
Gets all currently active store observers. | |
IReadOnlyCollection< DittoAttachmentFetcher > | AttachmentFetchers [get] |
Gets all currently active attachment fetchers. | |
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<DittoAttachmentFetcher, byte>() [get] |
Retrieve a DittoCollection . var collection = ditto.store["cars"]; | |
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.
|
inline |
A method to reference a DittoCollection
.
collectionName | The name of the collection. |
DittoCollection
.
|
inline |
Returns an object that lets you fetch or observe the collections in the store.
|
inline |
Executes a DQL query and returns matching items as a query result.
query | A string containing a valid query expressed in DQL. |
arguments | A dictionary of values keyed by the placeholder name without the leading : . Example: new Dictionary<string, object>()
{
{ "mileage", 123 }
}
|
DittoStoreException | Can throw a DittoStoreException. For more granular exception handling check its subtypes:
|
|
inline |
Fetch the attachment corresponding to the provided attachment token. Expects a dictionary representation of the token as returned in a DittoQueryResultItem
token | Dictionary representation of the token for the attachment that you want to fetch. |
onFetchEvent | An action that will be called when there is an update relating to the attachment fetch attempt. If the attachment is already available then this will be called almost immediately with a completed fetch event value. |
null
will be returned. This can happen if, for example, an invalid attachment token was provided.
|
inline |
Fetch the attachment corresponding to the provided attachment token.
token | The token for the attachment that you want to fetch. |
onFetchEvent | An action that will be called when there is an update relating to the attachment fetch attempt. If the attachment is already available then this will be called almost immediately with a completed fetch event value. |
DittoAttachmentNotFoundException | Attachment could not be found. |
DittoAttachmentTokenInvalidException | The provided token is invalid. |
DittoFailedToFetchAttachmentException | Error encountered trying to fetch the attachment. |
|
inline |
Creates a new attachment, which can then be inserted into a document.
The file residing at the provided path will be copied into Ditto's store. The DittoAttachment
object that is returned is what you can then use to insert an attachment into a document.
You can provide metadata about the attachment, which will be replicated to other peers alongside the file attachment.
Below is a snippet to show how you can use the NewAttachmentAsync
functionality to insert an attachment into a document.
var attachment = await store.NewAttachmentAsync("/path/to/my/file.zip"); if (attachment != null) { var document = new Dictionary<string, object>() { { "some", "string" }, { "myAttachment", attachment } }; Ditto.Store.ExecuteAsync( query: "INSERT INTO COLLECTION myCollection (myAttachment ATTACHMENT) DOCUMENTS (:document1)", arguments: new Dictionary<string, object>() { { "document1", document } } ); }
path | Path to the file on disk that will be used as the attachment. |
metadata | Optional metadata relating to the attachment. |
DittoAttachmentFileNotFoundException | File not found at the provided path. |
DittoAttachmentFilePermissionDeniedException | Permission denied error. |
DittoFailedToCreateAttachmentException | Error encountered trying to create the attachment. |
|
inline |
|
inline |
|
inline |
storeObservationHandler | A simplified callback containing the DittoQueryResult, where signalNext is automatically called when the handler finishes. |
|
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.
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. query | A string containing a valid query expressed in DQL. |
arguments | A dictionary of values keyed by the placeholder name without the leading : Example: new Dictionary<string, object>() { { "mileage" , 123 } }
|
storeObservationHandlerWithSignalNext | A 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. |
DittoStoreException | Can throw a DittoStoreException. For more granular exception handling check the following subtypes:
|
|
inline |
storeObservationHandlerTask | A simplified callback containing the DittoQueryResult, to be used in an async context, where signalNext is automatically called when the handler task finishes. |
|
inline |
|
inline |
Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.
handler | An Action that provides access to a write transaction object that can be used to perform operations on the store. |
|
get |
Gets the names of all collections known about on this device.
Note, this will return immediately what is in the store.
|
get |
Retrieve a DittoCollection
. var collection = ditto.store["cars"];
collectionName | The name of the collection. |
A collection name is valid if:
DittoCollection
.