5namespace Stroika::Foundation::Database::Document::ObjectCollection {
13 inline Ptr<T>::Ptr (
const Database::Document::Collection::Ptr& underlyingCollection,
const ObjectVariantMapper& mapper)
14 : inherited{underlyingCollection}
19 inline String Ptr<T>::Add (
const T& v)
21 return inherited::Add (fMapper_.FromObject (v).template As<Mapping<String, VariantValue>> ());
24 inline optional<T> Ptr<T>::GetOne (
const IDType&
id,
const optional<Projection>& projection)
26 if (optional<Document> o = inherited::GetOne (
id, projection)) {
27 return fMapper_.ToObject<T> (VariantValue{*o});
34 inline T Ptr<T>::GetOneOrThrow (
const IDType&
id,
const optional<Projection>& projection)
36 return fMapper_.ToObject<T> (VariantValue{inherited::GetOneOrThrow (
id, projection)});
39 Sequence<T> Ptr<T>::GetAll (
const optional<Filter>& filter,
const optional<Projection>& projection)
41 return inherited::GetAll (filter, projection).template Map<Sequence<T>> ([
this] (
const Document& d) {
42 return fMapper_.ToObject<T> (VariantValue{d});
46 inline void Ptr<T>::Replace (
const T& newV)
48 inherited::Replace (fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> ());
51 inline void Ptr<T>::Replace (
const IDType&
id,
const T& newV)
53 inherited::Replace (
id, fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> ());
56 inline void Ptr<T>::Update (
const T& newV,
const Set<String>& onlyTheseFields)
58 inherited::Update (fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> (), onlyTheseFields);
61 inline void Ptr<T>::Update (
const IDType&
id,
const T& newV,
const Set<String>& onlyTheseFields)
63 inherited::Update (
id, fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> (), onlyTheseFields);
72 inline Ptr<T> New (
const Database::Document::Collection::Ptr& underlyingCollection,
const ObjectVariantMapper& mapper)
74 return Ptr<T>{underlyingCollection, mapper};
Mapping< String, VariantValue > Document