add methods to add and find real estate - search request matches
This commit is contained in:
23
app/helpers/db/searchRequestMatch.js
Normal file
23
app/helpers/db/searchRequestMatch.js
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
const db = require("../../models/index");
|
||||
|
||||
const findRealEstatesForSearchRequest = async searchRequestId => {
|
||||
const query = {
|
||||
searchRequestId
|
||||
};
|
||||
|
||||
const include = [{ model: db.RealEstate }];
|
||||
|
||||
return await db.SearchRequestMatch.findAll({ where: query, include });
|
||||
};
|
||||
|
||||
const addMatches = async matchingRecords => {
|
||||
return await db.SearchRequestMatch.bulkCreate(matchingRecords, {
|
||||
ignoreDuplicates: true
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
findRealEstatesForSearchRequest,
|
||||
addMatches
|
||||
};
|
||||
Reference in New Issue
Block a user