Add upsert function.