"use strict";
const db = require("../../models/index");
const sequelize = require("sequelize");

const bulkUpsertKiviPhotos = async kiviPhotosData => {
  try {
    return await db.KiviOriginalAdsPhotos.bulkCreate(kiviPhotosData, {
      ignoreDuplicates: true
    });
  } catch (e) {
    console.log("Error bulk upserting kiviOriginalAdsPhotos : ", e);
  }
};

const findPhotosForKiviAd = async id => {
  try {
    return db.KiviOriginalAdsPhotos.findAll({
      where: {
        kiviAdId: id
      }
    });
  } catch (error) {
    console.log("kiviOriginalAdsPhotos.js", error);
    return null;
  }
};

module.exports = {
  bulkUpsertKiviPhotos,
  findPhotosForKiviAd
};
