Add generalized Upset and UpsertBy functions for models