Build util function to query with a default value if key is null.