summaryrefslogtreecommitdiffstats
path: root/common/domain
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-05-25 11:28:22 +0200
committerMinijackson <minijackson@riseup.net>2018-05-25 11:29:30 +0200
commit00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5 (patch)
treeeb0871b7518234c3db3e2d647b0b7c020253accb /common/domain
parentc095e82143fd16c84263d990b96590b3b0d12a78 (diff)
downloadsink-00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5.tar.gz
sink-00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5.zip
Implement range queries
Diffstat (limited to 'common/domain')
-rw-r--r--common/domain/typeimplementations.cpp5
-rw-r--r--common/domain/typeimplementations_p.h18
2 files changed, 20 insertions, 3 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp
index e65c998..a8f4baf 100644
--- a/common/domain/typeimplementations.cpp
+++ b/common/domain/typeimplementations.cpp
@@ -38,7 +38,7 @@ using namespace Sink::ApplicationDomain;
38 MAPPER.addMapping<ENTITYTYPE::PROPERTY, Sink::ApplicationDomain::Buffer::ENTITYTYPE, Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder>(&Sink::ApplicationDomain::Buffer::ENTITYTYPE::LOWERCASEPROPERTY, &Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder::add_##LOWERCASEPROPERTY); 38 MAPPER.addMapping<ENTITYTYPE::PROPERTY, Sink::ApplicationDomain::Buffer::ENTITYTYPE, Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder>(&Sink::ApplicationDomain::Buffer::ENTITYTYPE::LOWERCASEPROPERTY, &Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder::add_##LOWERCASEPROPERTY);
39 39
40typedef IndexConfig<Mail, 40typedef IndexConfig<Mail,
41 ValueIndex<Mail::Date>, 41 SortedIndex<Mail::Date>,
42 ValueIndex<Mail::Folder>, 42 ValueIndex<Mail::Folder>,
43 ValueIndex<Mail::ParentMessageId>, 43 ValueIndex<Mail::ParentMessageId>,
44 ValueIndex<Mail::MessageId>, 44 ValueIndex<Mail::MessageId>,
@@ -64,7 +64,8 @@ typedef IndexConfig<Addressbook,
64 > AddressbookIndexConfig; 64 > AddressbookIndexConfig;
65 65
66typedef IndexConfig<Event, 66typedef IndexConfig<Event,
67 ValueIndex<Event::Uid> 67 ValueIndex<Event::Uid>,
68 SortedIndex<Event::StartTime>
68 > EventIndexConfig; 69 > EventIndexConfig;
69 70
70typedef IndexConfig<Todo, 71typedef IndexConfig<Todo,
diff --git a/common/domain/typeimplementations_p.h b/common/domain/typeimplementations_p.h
index 6f77a2d..fc08048 100644
--- a/common/domain/typeimplementations_p.h
+++ b/common/domain/typeimplementations_p.h
@@ -62,7 +62,7 @@ public:
62}; 62};
63 63
64 64
65template <typename Property, typename SortProperty> 65template <typename Property, typename SortProperty = void>
66class SortedIndex 66class SortedIndex
67{ 67{
68public: 68public:
@@ -78,6 +78,22 @@ public:
78 } 78 }
79}; 79};
80 80
81template <typename SortProperty>
82class SortedIndex<SortProperty, void>
83{
84public:
85 static void configure(TypeIndex &index)
86 {
87 index.addSortedProperty<SortProperty>();
88 }
89
90 template <typename EntityType>
91 static QMap<QByteArray, int> databases()
92 {
93 return {{QByteArray{EntityType::name} +".index." + SortProperty::name + ".sorted", 1}};
94 }
95};
96
81template <typename Property, typename SecondaryProperty> 97template <typename Property, typename SecondaryProperty>
82class SecondaryIndex 98class SecondaryIndex
83{ 99{