WIP Bulk create not working.

This commit is contained in:
Naida Vatric
2020-01-21 01:19:35 +01:00
parent 0a181f742f
commit 42eddb3aa5
5 changed files with 46 additions and 7 deletions

View File

@@ -0,0 +1,19 @@
"use strict";
const db = require("../../models/index");
const sequelize = require("sequelize");
const bulkUpsertPriceHistory = async priceHistoryData => {
try {
const order = [["realEstateId", "desc"]];
return await db.PriceHistory.bulkCreate(priceHistoryData, {
order
});
} catch (e) {
console.log("Error bulk upserting priceHistory : ", e);
}
};
module.exports = {
bulkUpsertPriceHistory
};

View File

@@ -63,7 +63,9 @@ const bulkUpsertRealEstates = async realEstateData => {
"numberOfViewsAgency"
];
const order = [["updatedAt", "desc"]];
//
//console.log("realEstateData:", realEstateData);
//
return await db.RealEstate.bulkCreate(realEstateData, {
updateOnDuplicate: fieldsToUpdateIfDuplicate,
returning: true,