WIP Bulk create not working.
This commit is contained in:
19
app/helpers/db/priceHistory.js
Normal file
19
app/helpers/db/priceHistory.js
Normal 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
|
||||
};
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user