0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-01 21:28:53 +02:00

modules/console: db flush and sync commands.

This commit is contained in:
Jason Volk 2018-04-09 21:23:54 -07:00
parent 4b201b026e
commit d12b4bd259

View file

@ -520,6 +520,69 @@ console_cmd__mod__unload(opt &out, const string_view &line)
// db
//
bool
console_cmd__db__sync(opt &out, const string_view &line)
try
{
const params param{line, " ",
{
"dbname",
}};
const auto dbname
{
param.at(0)
};
auto &database
{
*db::database::dbs.at(dbname)
};
sync(database);
out << "done" << std::endl;
return true;
}
catch(const std::out_of_range &e)
{
out << "No open database by that name" << std::endl;
return true;
}
bool
console_cmd__db__flush(opt &out, const string_view &line)
try
{
const params param{line, " ",
{
"dbname", "[blocking]"
}};
const auto dbname
{
param.at(0)
};
const auto blocking
{
param.at(1, false)
};
auto &database
{
*db::database::dbs.at(dbname)
};
flush(database, blocking);
out << "done" << std::endl;
return true;
}
catch(const std::out_of_range &e)
{
out << "No open database by that name" << std::endl;
return true;
}
bool
console_cmd__db__prop(opt &out, const string_view &line)
{