new getKeyValuePairs helper function for database class