const db = require('../config/db');

async function setAmountOwned({ card_id, set_id, rarity_id, amount_owned }) {
  await db.execute(`
    INSERT INTO card_sets_rarity (card_id, set_id, rarity_id, amount_owned)
    VALUES (?, ?, ?, ?)
    ON DUPLICATE KEY UPDATE
      amount_owned = VALUES(amount_owned)
  `, [card_id, set_id, rarity_id, amount_owned]);

  return { card_id, set_id, rarity_id, amount_owned };
}

module.exports = { setAmountOwned };