WiP Changed welcome and input form for ad type
This commit is contained in:
11
app/helpers/db/kiviOriginal.js
Normal file
11
app/helpers/db/kiviOriginal.js
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
const db = require("../../models/index");
|
||||
const sequelize = require("sequelize");
|
||||
|
||||
const createKiviOriginal = async (kiviAdFields = {}) => {
|
||||
return await db.KiviOriginal.create(kiviAdFields);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
createKiviOriginal
|
||||
};
|
||||
@@ -77,7 +77,16 @@ const bulkUpsertRealEstates = async realEstateData => {
|
||||
};
|
||||
|
||||
const getRealEstateById = async id => {
|
||||
return db.RealEstate.findByPk(id);
|
||||
try {
|
||||
return db.RealEstate.findByPk(id);
|
||||
} catch (error) {
|
||||
console.log("realEstate.js", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const createRealEstate = async (realEstateFields = {}) => {
|
||||
return await db.RealEstate.create(realEstateFields);
|
||||
};
|
||||
|
||||
const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
@@ -344,5 +353,6 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
module.exports = {
|
||||
bulkUpsertRealEstates,
|
||||
getRealEstateById,
|
||||
createRealEstate,
|
||||
findRealEstatesForSearchRequest
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { getSearchRequest } = require("./db/searchRequest");
|
||||
const { getRealEstateById } = require("./db/realEstate");
|
||||
|
||||
const currentSearchRequest = async req => {
|
||||
const searchRequestId =
|
||||
@@ -7,6 +8,14 @@ const currentSearchRequest = async req => {
|
||||
|
||||
return await getSearchRequest(searchRequestId);
|
||||
};
|
||||
module.exports = {
|
||||
currentSearchRequest
|
||||
|
||||
const currentRealEstate = async req => {
|
||||
const realEstateId = req && req.params ? req.params["realEstateId"] : null;
|
||||
if (!realEstateId) return null;
|
||||
|
||||
return await getRealEstateById(realEstateId);
|
||||
};
|
||||
module.exports = {
|
||||
currentSearchRequest,
|
||||
currentRealEstate
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user