db: introduce support for reading out flags