|
| Collection (std::shared_ptr< DittoHandleWrapper > ditto_handle_wrapper, uint64_t site_id, std::string name, private_ctor &&) |
|
DocumentId | insert (nlohmann::json content, DocumentId id=DocumentId(), bool is_default=false) |
| Inserts a new document into the collection and returns the document's ID. More...
|
|
DocumentId | insert_with_strategy (nlohmann::json content, DocumentId id=DocumentId(), WriteStrategy write_strategy=WriteStrategy::overwrite) |
| Inserts a new document into the collection and returns the document's ID. More...
|
|
PendingIDSpecificOperation | find_by_id (DocumentId id) const |
| Generates a PendingIDSpecificOperation with the provided document ID that can be used to find the document at a point in time or you can chain a call to observe, observe_local, or subscribe if you want to get updates about the document over time. More...
|
|
PendingCursorOperation | find_all () |
| Generates a PendingCursorOperation that can be used to find all documents in the collection at a point in time or you can chain a call to observe, observe_local, or subscribe if you want to get updates about documents in the collection over time. More...
|
|
PendingCursorOperation | find (std::string query) |
| Generates a PendingCursorOperation with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call to observe, observe_local, or subscribe if you want to get updates about documents matching the query as they occur. More...
|
|
PendingCursorOperation | find (std::string query, nlohmann::json query_args) |
| Generates a PendingCursorOperation with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call to observe, observe_local, or subscribe if you want to get updates about documents matching the query as they occur. More...
|
|
Attachment | new_attachment (std::string path, std::map< std::string, std::string > metadata=std::map< std::string, std::string >()) |
| Creates a new attachment, which can then be inserted into a document. More...
|
|
std::shared_ptr< AttachmentFetcher > | fetch_attachment (std::shared_ptr< AttachmentToken > token, AttachmentFetcherEventHandler event_handler) |
| Trigger an attachment to be downloaded locally to the device and observe its progress as it does so. More...
|
|
A reference to a collection in a Store
.
Generates a PendingCursorOperation
with the provided query that can be used to find the documents matching the query at a point in time or you can chain a call to observe, observe_local, or subscribe if you want to get updates about documents matching the query as they occur.
This is the recommended function 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[in] | the query to run against the collection. |
query_args[in] | the arguments to use to replace placeholders in the provided query. |
- Returns
- a
PendingCursorOperation
that you can use to chain further query-related function calls.
Attachment ditto::Collection::new_attachment |
( |
std::string |
path, |
|
|
std::map< std::string, std::string > |
metadata = std::map<std::string, std::string>() |
|
) |
| |
Creates a new attachment, which can then be inserted into a document.
The file residing at the provided path will be copied into the Ditto's store. The Attachment
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 new_attachment functionality to insert an attachment into a document.
auto attachment = collection.new_attachment("/path/to/my/file.pdf");
auto docID = collection.insert(json{{"attachment", attachment}, {"other",
"string"}});
- Parameters
-
[in] | path | the path to the file that you want to create an attachment with. |
[in] | metadata | metadata relating to the attachment. |
- Returns
- an
Attachment
object, which can be used to insert the attachment into a document.