WIP Bulk create not working.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const moment = require("moment");
|
||||
|
||||
const { bulkUpsertRealEstates } = require("../../helpers/db/realEstate");
|
||||
const { bulkUpsertPriceHistory } = require("../../helpers/db/priceHistory");
|
||||
|
||||
class PostgresSaver {
|
||||
connect() {
|
||||
@@ -11,7 +12,17 @@ class PostgresSaver {
|
||||
|
||||
async save(results) {
|
||||
const savedRecords = await bulkUpsertRealEstates(results);
|
||||
|
||||
//Extruding data for price history table
|
||||
const resultPrices = savedRecords.map(realEstate => {
|
||||
return {
|
||||
realEstateId: realEstate.dataValues.id,
|
||||
price: realEstate.dataValues.price
|
||||
};
|
||||
});
|
||||
const savedPrices = await bulkUpsertPriceHistory(resultPrices);
|
||||
//
|
||||
console.log("savedPrices", savedPrices);
|
||||
//
|
||||
if (Array.isArray(savedRecords)) {
|
||||
const newRealEstates = [];
|
||||
const existingRealEstates = [];
|
||||
|
||||
Reference in New Issue
Block a user