1#ifndef DITTO_COLLECTION_H
2#define DITTO_COLLECTION_H
4#include "Attachment.hpp"
5#include "AttachmentFetchEvent.hpp"
6#include "AttachmentFetcher.hpp"
7#include "AttachmentToken.hpp"
8#include "DocumentId.hpp"
10#include "PendingCursorOperation.hpp"
11#include "PendingIDSpecificOperation.hpp"
12#include "WriteStrategy.hpp"
21class DittoHandleWrapper;
29class DITTO_DEPRECATED_BECAUSE(
30 "Use DQL (Ditto Query Language) instead. For more information see: "
31 "https://ditto.com/link/legacy-to-dql-guide") Collection {
32 DITTO_DISABLE_DEPRECATED_WARNINGS(
"The legacy query API is deprecated")
35 friend class DocumentHelpers;
36 friend class ScopedWriteTransaction;
39 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
41 struct private_ctor {};
43 Collection(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
47 CWriteTransaction *txn)
const;
51 Collection(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
52 std::string
name, private_ctor &&);
135 nlohmann::json query_args)
const;
166 std::string path, std::map<std::string, std::string> metadata =
167 std::map<std::string, std::string>())
const;
191 DITTO_DEPRECATED std::shared_ptr<AttachmentFetcher>
195 DITTO_REENABLE_WARNINGS
Represents an attachment and can be used to insert the associated attachment into a document at a spe...
Definition Attachment.hpp:22
PendingCursorOperation find(std::string query) const
Generates a PendingCursorOperation with the provided query that can be used to find the documents mat...
PendingIDSpecificOperation find_by_id(DocumentId id) const
Generates a PendingIDSpecificOperation with the provided document ID that can be used to find the doc...
std::string name
The name of the collection.
Definition Collection.hpp:59
PendingCursorOperation find(std::string query, nlohmann::json query_args) const
Generates a PendingCursorOperation with the provided query that can be used to find the documents mat...
PendingCursorOperation find_all() const
Generates a PendingCursorOperation that can be used to find all documents in the collection at a poin...
std::shared_ptr< AttachmentFetcher > fetch_attachment(std::shared_ptr< AttachmentToken > token, AttachmentFetcherEventHandler event_handler) const
Trigger an attachment to be downloaded locally to the device and observe its progress as it does so.
Attachment new_attachment(std::string path, std::map< std::string, std::string > metadata=std::map< std::string, std::string >()) const
Creates a new attachment, which can then be inserted into a document.
DocumentId upsert(nlohmann::json content, WriteStrategy write_strategy=WriteStrategy::merge) const
Inserts a new document into the collection and returns its ID. If the document already exists,...
These objects are returned when using find-like functionality on Collection objects.
Definition PendingCursorOperation.hpp:49
These objects are returned when using Collection::find_by_id functionality.
Definition PendingIDSpecificOperation.hpp:45
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
WriteStrategy
Definition WriteStrategy.hpp:17
@ merge
Definition WriteStrategy.hpp:22
A thin wrapper around a function that will get called when there are updates relating to an attempt t...
Definition AttachmentFetcher.hpp:19
An identifier for a Document.
Definition DocumentId.hpp:23