Ditto 1.1.8
Public Member Functions | Properties | List of all members
DittoSDK.DittoScopedWriteTransaction Class Reference

Exposes functionality that allows you to perform multiple operations on the store within a single write transaction. More...

Public Member Functions

unsafe DittoDocumentID Upsert (Dictionary< string, object > data, DittoWriteStrategy writeStrategy=DittoWriteStrategy.Merge)
 Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given writeStrategy. More...
 
unsafe DittoDocumentID Insert (Dictionary< string, object > data, DittoDocumentID id=null, bool isDefault=false)
 Inserts a document into a collection. More...
 
unsafe DittoDocumentID InsertWithStrategy (Dictionary< string, object > data, DittoDocumentID id=null, DittoWriteStrategy writeStrategy=DittoWriteStrategy.Overwrite)
 Inserts a document into a collection. More...
 
DittoWriteTransactionPendingCursorOperation Find (string query)
 Creates a cursor for the documents in this collection that match the provided query. More...
 
DittoWriteTransactionPendingCursorOperation Find (string query, Dictionary< string, object > queryArgs)
 Creates a cursor for the documents in this collection that match the provided query, with any placeholders replaced by the relevant provided query arguments. More...
 
DittoWriteTransactionPendingCursorOperation FindAll ()
 Creates a cursor for all of the documents in this collection. More...
 
DittoWriteTransactionPendingIDSpecificOperation FindById (DittoDocumentID id)
 Creates an accessor for a single document by its unique identifier. More...
 

Properties

string CollectionName [get]
 Gets the name of the collection that the scoped write transaction is scoped to.
 

Detailed Description

Exposes functionality that allows you to perform multiple operations on the store within a single write transaction.

A DittoScopedWriteTransaction is scoped to a specific collection, obtained by calling DittoWriteTransaction.Scoped(string).

Member Function Documentation

◆ Find() [1/2]

DittoWriteTransactionPendingCursorOperation DittoSDK.DittoScopedWriteTransaction.Find ( string  query)
inline

Creates a cursor for the documents in this collection that match the provided query.

Parameters
queryA ditto query string.
Returns
A cursor for the query.

◆ Find() [2/2]

DittoWriteTransactionPendingCursorOperation DittoSDK.DittoScopedWriteTransaction.Find ( string  query,
Dictionary< string, object >  queryArgs 
)
inline

Creates a cursor for the documents in this collection that match the provided query, with any placeholders replaced by the relevant provided query arguments.

This is the recommended method to use when performing queries on a collection if you have any dynamic data included in the query string. It allows you to provide a query string with placeholders, in the form of $args.my_arg_name, along with an accompanying dictionary of arguments, in the form of { "my_arg_name": "some value" }, and the placeholders will be appropriately replaced by the matching provided arguments from the dictionary. This includes handling things like wrapping strings in quotation marks and arrays in square brackets, for example.

Parameters
queryA ditto query string.
queryArgsThe arguments to use to replace placeholders in the provided query.
Returns
A cursor for the query.

◆ FindAll()

DittoWriteTransactionPendingCursorOperation DittoSDK.DittoScopedWriteTransaction.FindAll ( )
inline

Creates a cursor for all of the documents in this collection.

Returns
A cursor for all documents in the collection.

◆ FindById()

DittoWriteTransactionPendingIDSpecificOperation DittoSDK.DittoScopedWriteTransaction.FindById ( DittoDocumentID  id)
inline

Creates an accessor for a single document by its unique identifier.

Parameters
idThe id of the document in this collection.
Returns
A cursor for a single document.

◆ Insert()

unsafe DittoDocumentID DittoSDK.DittoScopedWriteTransaction.Insert ( Dictionary< string, object >  data,
DittoDocumentID  id = null,
bool  isDefault = false 
)
inline

Inserts a document into a collection.

Parameters
dataThe document content.
idThe primary key or identifier for this document. If this is null then Ditto will assign it a unique identifier. This cannot be changed once inserted.
isDefaultSet to true if the document should assume all values are default. See https://docs.ditto.live/concepts/data-model.
Returns
The unique identifier of the document.

◆ InsertWithStrategy()

unsafe DittoDocumentID DittoSDK.DittoScopedWriteTransaction.InsertWithStrategy ( Dictionary< string, object >  data,
DittoDocumentID  id = null,
DittoWriteStrategy  writeStrategy = DittoWriteStrategy.Overwrite 
)
inline

Inserts a document into a collection.

Parameters
dataThe document content.
idThe primary key or identifier for this document. If this is null then Ditto will assign it a unique identifier. This cannot be changed once inserted.
writeStrategySpecifies the desired strategy for inserting a document. The default value is DittoWriteStrategy.Overwrite.
Returns
The unique identifier of the document.

◆ Upsert()

unsafe DittoDocumentID DittoSDK.DittoScopedWriteTransaction.Upsert ( Dictionary< string, object >  data,
DittoWriteStrategy  writeStrategy = DittoWriteStrategy.Merge 
)
inline

Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given writeStrategy.

Parameters
dataThe document content.
writeStrategySpecifies the desired strategy for inserting a document. The default value is DittoWriteStrategy.Merge.
Returns
The unique identifier of the document.