database: pagedao: Add findByTitle()

这个提交包含在:
2022-03-29 22:30:20 +02:00
父节点 03c5646858
当前提交 3e736db0ef
修改 3 个文件,包含 22 行新增0 行删除

查看文件

@@ -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;