feat(db): impl get_group

Former-commit-id: d40df7e09e60dfa682d28481a2fe320d57819baa
This commit is contained in:
Xu Peng 2019-04-18 09:54:50 +08:00
parent e47b6cf9cc
commit 92e30f4e7a

View File

@ -71,8 +71,23 @@ Status DBMetaImpl::add_group(GroupSchema& group_info) {
return Status::OK();
}
Status DBMetaImpl::get_group(GroupSchema& group_info_) {
Status DBMetaImpl::get_group(GroupSchema& group_info) {
auto groups = ConnectorPtr->select(columns(&GroupSchema::id,
&GroupSchema::group_id,
&GroupSchema::files_cnt,
&GroupSchema::dimension),
where(c(&GroupSchema::group_id) == group_info.group_id));
assert(groups.size() <= 1);
if (groups.size() == 1) {
group_info.id = std::get<0>(groups[0]);
group_info.files_cnt = std::get<2>(groups[0]);
group_info.dimension = std::get<3>(groups[0]);
} else {
return Status::NotFound("Group " + group_info.group_id + " not found");
}
std::cout << __func__ << ": gid=" << group_info.group_id
<< " dimension=" << group_info.dimension << std::endl;
return Status::OK();
}