[Database] Added an upsert() function to perform/emulate ON DUPLICATE KEY UPDATE.