42 lines
840 B
JavaScript
42 lines
840 B
JavaScript
"use strict";
|
|
const db = require("../../models/index");
|
|
|
|
const bulkUpsertRealEstates = async realEstateData => {
|
|
try {
|
|
const fieldsToUpdateIfDuplicate = [
|
|
"realEstateType",
|
|
"adType",
|
|
"price",
|
|
"area",
|
|
"streetNumber",
|
|
"streetName",
|
|
"locality",
|
|
"municipality",
|
|
"city",
|
|
"region",
|
|
"entity",
|
|
"country",
|
|
"locationLat",
|
|
"locationLong",
|
|
"title",
|
|
"shortDescription",
|
|
"longDescription",
|
|
"gardenSize",
|
|
"adStatus",
|
|
"updatedAt",
|
|
"renewedDate"
|
|
];
|
|
|
|
return await db.RealEstate.bulkCreate(realEstateData, {
|
|
updateOnDuplicate: fieldsToUpdateIfDuplicate,
|
|
returning: true
|
|
});
|
|
} catch (e) {
|
|
console.log("Error bulk upserting realEstates : ", e);
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
bulkUpsertRealEstates
|
|
};
|