1#ifndef _DITTO_COLLECTION_
2#define _DITTO_COLLECTION_
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;
28 friend class DocumentHelpers;
32 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
34 struct private_ctor {};
36 Collection(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
40 CWriteTransaction *txn)
const;
44 Collection(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
45 std::string
name, private_ctor &&);
65 WriteStrategy write_strategy = WriteStrategy::merge)
const;
153 std::map<std::string, std::string> metadata =
154 std::map<std::string, std::string>())
const;
176 std::shared_ptr<AttachmentFetcher>
Represents an attachment and can be used to insert the associated attachment into a document at a spe...
Definition Attachment.hpp:22
A reference to a collection in a Store.
Definition Collection.hpp:26
PendingCursorOperation find(std::string query) const
Generates a PendingCursorOperation with the provided query that can be used to find the documents mat...
Definition Collection.cpp:40
PendingIDSpecificOperation find_by_id(DocumentId id) const
Generates a PendingIDSpecificOperation with the provided document ID that can be used to find the doc...
Definition Collection.cpp:32
std::string name
The name of the collection.
Definition Collection.hpp:50
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...
Definition Collection.cpp:36
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.
Definition Collection.cpp:74
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.
Definition Collection.cpp:52
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:44
These objects are returned when using Collection::find_by_id functionality.
Definition PendingIDSpecificOperation.hpp:40
ScopedWriteTransaction exposes functionality that allows you to perform multiple operations on the st...
Definition ScopedWriteTransaction.hpp:23
Provides access to Collections and a write transaction API.
Definition Store.hpp:25
basic_json<> json
default JSON class
Definition json.hpp:2933
A thin wrapper around a function that will get called when there are updates relating to an attempt t...
Definition AttachmentFetcher.hpp:18
An identifier for a Document.
Definition DocumentId.hpp:21