Added real estate ad edit ability
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
const db = require("../../models/index");
|
||||
|
||||
const sequelize = require("sequelize");
|
||||
const Op = sequelize.Op;
|
||||
|
||||
const bulkUpsertKiviPhotos = async kiviPhotosData => {
|
||||
try {
|
||||
@@ -25,7 +27,25 @@ const findPhotosForKiviAd = async id => {
|
||||
}
|
||||
};
|
||||
|
||||
const deleteUrlPhotosAfterUpdate = async photoUrlsToKeep => {
|
||||
//We delete all urls that are not in "newly changed - edited" photo urls array
|
||||
const deleteQuery = {
|
||||
photoUrl: {
|
||||
[Op.notIn]: photoUrlsToKeep
|
||||
}
|
||||
};
|
||||
try {
|
||||
return db.KiviOriginalAdsPhotos.destroy({
|
||||
where: deleteQuery
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("kiviOriginalAdsPhotos.js", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
bulkUpsertKiviPhotos,
|
||||
findPhotosForKiviAd
|
||||
findPhotosForKiviAd,
|
||||
deleteUrlPhotosAfterUpdate
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user