Add support for saving metadata on queries.

Took your suggestion.