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...
|
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
|
|
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.
Task< DittoAttachment > DittoSDK.DittoStore.NewAttachmentAsync |
( |
string | path, |
|
|
Dictionary< string, string > | metadata = null ) |
|
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 }
}
);
}
- Parameters
-
path | Path to the file on disk that will be used as the attachment. |
metadata | Optional metadata relating to the attachment. |
- Returns
- A DittoAttachment object, which can be used to insert the attachment into a document
- Exceptions
-
DittoAttachmentFileNotFoundException | File not found at the provided path. |
DittoAttachmentFilePermissionDeniedException | Permission denied error. |
DittoFailedToCreateAttachmentException | Error encountered trying to create the attachment. |