mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
modules/console: Split db compact into db compact files.
This commit is contained in:
parent
4f1b9b6f6f
commit
f1556f880e
1 changed files with 54 additions and 2 deletions
|
@ -1493,8 +1493,60 @@ try
|
|||
};
|
||||
|
||||
compact(column, range, level);
|
||||
}};
|
||||
|
||||
if(colname != "*")
|
||||
compact_column(colname);
|
||||
else
|
||||
for(const auto &column : database.columns)
|
||||
compact_column(name(*column));
|
||||
|
||||
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__compact__files(opt &out, const string_view &line)
|
||||
try
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"dbname", "[colname]", "[level]"
|
||||
}};
|
||||
|
||||
const auto dbname
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
const auto colname
|
||||
{
|
||||
param.at(1, "*"_sv)
|
||||
};
|
||||
|
||||
const auto level
|
||||
{
|
||||
param.at(2, -1)
|
||||
};
|
||||
|
||||
auto &database
|
||||
{
|
||||
db::database::get(dbname)
|
||||
};
|
||||
|
||||
const auto compact_column{[&out, &database, &level]
|
||||
(const string_view &colname)
|
||||
{
|
||||
db::column column
|
||||
{
|
||||
database, colname
|
||||
};
|
||||
|
||||
if(level >= -1 && range.first.empty() && range.second.empty())
|
||||
compact(column, level);
|
||||
}};
|
||||
|
||||
|
|
Loading…
Reference in a new issue