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 auto Ptr<T>::Add (
const T& v)
const ->
IDType
21 return inherited::Add (fMapper_.FromObject (v).template As<Mapping<String, VariantValue>> ());
24 inline optional<T> Ptr<T>::Get (
const IDType&
id,
const optional<Projection>& projection)
const
26 if (optional<Document> o = inherited::Get (
id, projection)) {
27 return fMapper_.ToObject<T> (VariantValue{*o});
34 inline optional<T> Ptr<T>::Get (
const Filter& filter,
const optional<Projection>& projection)
const
36 if (optional<Document> o = inherited::Get (filter, projection)) {
37 return fMapper_.ToObject<T> (VariantValue{*o});
44 inline T Ptr<T>::GetOrThrow (
const IDType&
id,
const optional<Projection>& projection)
const
46 return fMapper_.ToObject<T> (VariantValue{inherited::GetOrThrow (
id, projection)});
49 inline T Ptr<T>::GetOrThrow (
const Filter& filter,
const optional<Projection>& projection)
const
51 return fMapper_.ToObject<T> (VariantValue{inherited::GetOrThrow (filter, projection)});
54 Sequence<T> Ptr<T>::GetAll (
const optional<Filter>& filter,
const optional<Projection>& projection)
const
56 return inherited::GetAll (filter, projection).template Map<Sequence<T>> ([
this] (
const Document& d) {
57 return fMapper_.ToObject<T> (VariantValue{d});
61 inline void Ptr<T>::Replace (
const T& newV)
const
63 inherited::Replace (fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> ());
66 inline void Ptr<T>::Replace (
const IDType&
id,
const T& newV)
const
68 inherited::Replace (
id, fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> ());
71 inline void Ptr<T>::Update (
const T& newV,
const Set<String>& onlyTheseFields)
const
73 inherited::Update (fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> (), onlyTheseFields);
76 inline void Ptr<T>::Update (
const IDType&
id,
const T& newV,
const Set<String>& onlyTheseFields)
const
78 inherited::Update (
id, fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> (), onlyTheseFields);
81 inline auto Ptr<T>::AddOrUpdate (
const T& newV)
const ->
IDType
83 return inherited::AddOrUpdate (fMapper_.FromObject (newV).template As<Mapping<String, VariantValue>> ());
92 inline Ptr<T> New (
const Database::Document::Collection::Ptr& underlyingCollection,
const ObjectVariantMapper& mapper)
94 return Ptr<T>{underlyingCollection, mapper};
Mapping< String, VariantValue > Document