[EGD-4553] Notes search engine implemented. (#1112)

This commit is contained in:
Piotr Tanski
2020-12-01 10:30:38 +01:00
committed by GitHub
parent 3a924e7d42
commit 5d757a6dc0
27 changed files with 605 additions and 12 deletions

View File

@@ -4,6 +4,7 @@
#include "NotesRepository.hpp"
#include <module-db/queries/notes/QueryNotesGet.hpp>
#include <module-db/queries/notes/QueryNotesGetByText.hpp>
#include <module-db/queries/notes/QueryNoteStore.hpp>
#include <module-db/queries/notes/QueryNoteRemove.hpp>
@@ -30,6 +31,22 @@ namespace app::notes
DBServiceAPI::GetQuery(application, db::Interface::Name::Notes, std::move(query));
}
void NotesDBRepository::getByText(const std::string &text, const OnFilteredCallback &callback)
{
auto query = std::make_unique<db::query::QueryNotesGetByText>(text);
query->setQueryListener(db::QueryCallback::fromFunction([callback](auto response) {
auto result = dynamic_cast<db::query::NotesGetByTextResult *>(response);
if (result == nullptr) {
return false;
}
if (callback) {
callback(result->getRecords());
}
return true;
}));
DBServiceAPI::GetQuery(application, db::Interface::Name::Notes, std::move(query));
}
void NotesDBRepository::save(const NotesRecord &note, const OnResultCallback &callback)
{
auto query = std::make_unique<db::query::QueryNoteStore>(note);