Add upsert method, toJSON, raw methods