Exposes functionality that allows you to perform multiple operations on the store within a single write transaction.
More...
|
string | CollectionName [get] |
| Gets the name of the collection that the scoped write transaction is scoped to.
|
|
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).
◆ Find() [1/2]
Creates a cursor for the documents in this collection that match the provided query.
- Parameters
-
query | A ditto query string. |
- Returns
- A cursor for the query.
◆ Find() [2/2]
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
-
query | A ditto query string. |
queryArgs | The arguments to use to replace placeholders in the provided query. |
- Returns
- A cursor for the query.
◆ FindAll()
Creates a cursor for all of the documents in this collection.
- Returns
- A cursor for all documents in the collection.
◆ FindById()
Creates an accessor for a single document by its unique identifier.
- Parameters
-
id | The id of the document in this collection. |
- Returns
- A cursor for a single document.
◆ Upsert()
Inserts a new document into the collection and returns its identifier. If the document already exists, the behavior is determined by the given writeStrategy
.
This method will update an existing document if you provide an _id
value and a document with that identifier exists in the collection.
Below is a snippet to show how you can use the Upsert
functionality to update a document.
var docId = coll.Upsert(new Dictionary<string, object> { { "_id", new DittoDocumentId("customId") }, { "some", "string" }, });
- Parameters
-
data | The document content. |
writeStrategy | Specifies the desired strategy for inserting a document. The default value is DittoWriteStrategy.Merge . |
- Returns
- The unique identifier of the document.