4. Making queries

This tutorial is a follow-up to Creating and configuring a session and potentially one of Loading repositories (to have some packages to query for), you can prepend them directly for a functional piece of code.

 1#include <libdnf5/rpm/package_query.hpp>
 2
 3// Create a package query.
 4libdnf5::rpm::PackageQuery query(base);
 5
 6// Filter the packages, the filters can be stacked one after another.
 7query.filter_name("one");
 8
 9// Iterate over the filtered packages in the query.
10for (const auto & pkg : query) {
11    std::cout << pkg.get_nevra() << std::endl;
12}