0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-29 04:08:54 +02:00

modules/console: Add ability to query prop for all columns with "**" key.

This commit is contained in:
Jason Volk 2018-04-14 21:44:58 -07:00
parent f37176d698
commit f0dc31d284

View file

@ -611,6 +611,7 @@ try
*db::database::dbs.at(dbname) *db::database::dbs.at(dbname)
}; };
// Special branch for integer properties that RocksDB aggregates.
if(colname == "*") if(colname == "*")
{ {
const uint64_t value const uint64_t value
@ -622,6 +623,9 @@ try
return true; return true;
} }
const auto query{[&out, &database, &property]
(const string_view &colname)
{
const db::column column const db::column column
{ {
database, colname database, colname
@ -633,7 +637,22 @@ try
}; };
for(const auto &p : value) for(const auto &p : value)
out << p.first << " => " << p.second << std::endl; out << p.first << " : " << p.second << std::endl;
}};
// Branch for querying the property for a single column
if(colname != "**")
{
query(colname);
return true;
}
// Querying the property for all columns in a loop
for(const auto &column_name : database.column_names)
{
out << std::setw(16) << std::right << column_name << " : ";
query(column_name);
}
return true; return true;
} }