database: pagedao: Add findByTitle()

This commit is contained in:
2022-03-29 22:30:20 +02:00
parent 03c5646858
commit 3e736db0ef
3 changed files with 22 additions and 0 deletions

View File

@@ -52,6 +52,26 @@ std::optional<Page> PageDaoSqlite::find(std::string name)
}
}
std::optional<Page> PageDaoSqlite::findByTitle(std::string title)
{
Page result;
try
{
auto ps = *db << "SELECT id, name, title, lastrevision, visible FROM page WHERE title = ?";
ps << title >> std::tie(result.pageid, result.name, result.title, result.current_revision, result.listed);
}
catch(const sqlite::errors::no_rows &e)
{
return {};
}
catch(sqlite::sqlite_exception &e)
{
throwFrom(e);
}
return result;
}
std::optional<Page> PageDaoSqlite::find(unsigned int id)
{
Page result;