diff --git a/.gitignore b/.gitignore index b70adccf..27041698 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,6 @@ $RECYCLE.BIN/ # Ignore public folder /static + +# Ignore data dumps from MongoDB +dump/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7474e47d..d5df3977 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3916,11 +3916,12 @@ } }, "node_modules/body-parser": { - "version": "1.20.1", - "license": "MIT", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -3928,7 +3929,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -3939,18 +3940,21 @@ }, "node_modules/body-parser/node_modules/debug": { "version": "2.6.9", - "license": "MIT", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dependencies": { "ms": "2.0.0" } }, "node_modules/body-parser/node_modules/ms": { "version": "2.0.0", - "license": "MIT" + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/body-parser/node_modules/on-finished": { "version": "2.4.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dependencies": { "ee-first": "1.1.1" }, @@ -4070,7 +4074,8 @@ }, "node_modules/bytes": { "version": "3.1.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "engines": { "node": ">= 0.8" } @@ -4432,8 +4437,9 @@ "license": "MIT" }, "node_modules/content-type": { - "version": "1.0.4", - "license": "MIT", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", "engines": { "node": ">= 0.6" } @@ -5122,15 +5128,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "license": "MIT", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -5259,8 +5266,9 @@ } }, "node_modules/express/node_modules/cookie": { - "version": "0.5.0", - "license": "MIT", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -5780,7 +5788,8 @@ }, "node_modules/iconv-lite": { "version": "0.4.24", - "license": "MIT", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -5882,9 +5891,9 @@ "license": "ISC" }, "node_modules/ip": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", - "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", + "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==" }, "node_modules/ipaddr.js": { "version": "1.9.1", @@ -6953,11 +6962,9 @@ "license": "MIT" }, "node_modules/minipass": { - "version": "4.0.0", - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "engines": { "node": ">=8" } @@ -7258,8 +7265,9 @@ "license": "MIT" }, "node_modules/nodemailer": { - "version": "6.8.0", - "license": "MIT", + "version": "6.9.13", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.13.tgz", + "integrity": "sha512-7o38Yogx6krdoBf3jCAqnIN4oSQFx+fMa0I7dK1D+me9kBxx12D+/33wSb+fhOCtIxvYJ+4x4IMEhmhCKfAiOA==", "engines": { "node": ">=6.0.0" } @@ -7782,8 +7790,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "license": "MIT", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -8003,7 +8012,8 @@ }, "node_modules/safer-buffer": { "version": "2.1.2", - "license": "MIT" + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/saslprep": { "version": "1.0.3", @@ -8424,12 +8434,13 @@ } }, "node_modules/tar": { - "version": "6.1.13", - "license": "ISC", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -11657,10 +11668,12 @@ } }, "body-parser": { - "version": "1.20.1", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "requires": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -11668,22 +11681,28 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, "dependencies": { "debug": { "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "requires": { "ms": "2.0.0" } }, "ms": { - "version": "2.0.0" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "on-finished": { "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "requires": { "ee-first": "1.1.1" } @@ -11754,7 +11773,9 @@ } }, "bytes": { - "version": "3.1.2" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, "call-bind": { "version": "1.0.2", @@ -11969,7 +11990,9 @@ } }, "content-type": { - "version": "1.0.4" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==" }, "convert-source-map": { "version": "1.7.0", @@ -12384,14 +12407,16 @@ } }, "express": { - "version": "4.18.2", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -12420,7 +12445,9 @@ }, "dependencies": { "cookie": { - "version": "0.5.0" + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==" }, "debug": { "version": "2.6.9", @@ -12796,6 +12823,8 @@ }, "iconv-lite": { "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -12850,9 +12879,9 @@ "version": "2.0.4" }, "ip": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", - "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", + "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==" }, "ipaddr.js": { "version": "1.9.1" @@ -13567,10 +13596,9 @@ "version": "1.2.6" }, "minipass": { - "version": "4.0.0", - "requires": { - "yallist": "^4.0.0" - } + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==" }, "minizlib": { "version": "2.1.2", @@ -13760,7 +13788,9 @@ "version": "2.0.7" }, "nodemailer": { - "version": "6.8.0" + "version": "6.9.13", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.13.tgz", + "integrity": "sha512-7o38Yogx6krdoBf3jCAqnIN4oSQFx+fMa0I7dK1D+me9kBxx12D+/33wSb+fhOCtIxvYJ+4x4IMEhmhCKfAiOA==" }, "nodemailer-express-handlebars": { "version": "5.0.0", @@ -14064,7 +14094,9 @@ } }, "raw-body": { - "version": "2.5.1", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "requires": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -14199,7 +14231,9 @@ "version": "5.1.2" }, "safer-buffer": { - "version": "2.1.2" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "saslprep": { "version": "1.0.3", @@ -14479,11 +14513,13 @@ "dev": true }, "tar": { - "version": "6.1.13", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -14772,4 +14808,4 @@ "dev": true } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index dd3783a2..f40ee259 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "babel-plugin-transform-import-meta": "^2.2.0", "eslint": "^8.29.0", "jest": "^29.3.1", - "nodemon": "^2.0.20", + "nodemon": "^3.0.1", "npm-audit-helper": "^3.1.1", "supertest": "^6.3.3" }, diff --git a/seed.sh b/seed.sh new file mode 100755 index 00000000..649dd732 --- /dev/null +++ b/seed.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +mongorestore --uri mongodb://localhost:27017 \ No newline at end of file diff --git a/src/api/middleware/validators/company.js b/src/api/middleware/validators/company.js index 82fe9fa4..de202522 100644 --- a/src/api/middleware/validators/company.js +++ b/src/api/middleware/validators/company.js @@ -131,6 +131,4 @@ export const edit = useExpressValidators([ .withMessage(ValidationReasons.ARRAY_SIZE(CompanyConstants.contacts.min_length, CompanyConstants.contacts.max_length)), body("logo", ValidationReasons.DEFAULT) .optional() - .isString().withMessage(ValidationReasons.STRING).bail() - .isURL().withMessage(ValidationReasons.URL), ]); diff --git a/src/api/routes/company.js b/src/api/routes/company.js index 01db8ab2..fa1ff69b 100644 --- a/src/api/routes/company.js +++ b/src/api/routes/company.js @@ -13,7 +13,7 @@ import { concurrentOffersNotExceeded } from "../middleware/validators/validatorU import { or } from "../middleware/utils.js"; -import * as fileMiddleware from "../middleware/files.js"; +import * as fileMiddleware from "../middleware/files.js"; import OfferService from "../../services/offer.js"; import AccountService from "../../services/account.js"; import Offer from "../../models/Offer.js"; @@ -245,7 +245,8 @@ export default (app) => { try { const companyService = new CompanyService(); const offerService = new OfferService(); - const company = await companyService.changeAttributes(req.params.companyId, req.body); + const logo = req.file && (req?.file?.url || `${config.webserver_host}/static/${req.file.filename}`); + const company = await companyService.changeAttributes(req.params.companyId, { ...req.body, logo }); await offerService.updateAllOffersByCompanyId(company); return res.json(company); } catch (err) { diff --git a/src/services/offer.js b/src/services/offer.js index 025e2094..e0991cc4 100644 --- a/src/services/offer.js +++ b/src/services/offer.js @@ -1,10 +1,10 @@ import mongoose from "mongoose"; -import Company from "../models/Company.js"; -import Offer from "../models/Offer.js"; -import Account from "../models/Account.js"; -import EmailService from "../lib/emailService.js"; -import { OFFER_DISABLED_NOTIFICATION } from "../email-templates/companyOfferDisabled.js"; -import OfferConstants from "../models/constants/Offer.js"; +import Company from "../models/Company.js"; +import Offer from "../models/Offer.js"; +import Account from "../models/Account.js"; +import EmailService from "../lib/emailService.js"; +import { OFFER_DISABLED_NOTIFICATION } from "../email-templates/companyOfferDisabled.js"; +import OfferConstants from "../models/constants/Offer.js"; import CompanyConstants from "../models/constants/Company.js"; import base64url from "base64url"; @@ -271,10 +271,12 @@ class OfferService { * Otherwise, use _buildSearchContinuationQuery(). */ _buildInitialSearchQuery(value, showHidden, showAdminReason, filters) { - const offers = (value ? Offer.find({ "$and": [ - this._buildFilterQuery(filters), - { "$text": { "$search": value } } - ] }, { score: { "$meta": "textScore" } } + const offers = (value ? Offer.find({ + "$and": [ + this._buildFilterQuery(filters), + { "$text": { "$search": value } } + ] + }, { score: { "$meta": "textScore" } } ) : Offer.find(this._buildFilterQuery(filters))); @@ -294,26 +296,36 @@ class OfferService { offers = Offer.aggregate([ { $match: { $text: { $search: value } } }, { $match: this._buildFilterQuery(filters) }, - { $addFields: { - score: { $meta: "textScore" }, - adminReason: { $cond: [showAdminReason, "$adminReason", "$$REMOVE"] } - } }, - { $match: { "$or": [ - { score: { "$lt": lastOfferScore } }, - { score: lastOfferScore, [lastSortField]: { [sortFieldOperator]: lastSortValue } }, - { score: lastOfferScore, [lastSortField]: lastSortValue, _id: { "$gt": ObjectId(lastOfferId) } } - ] } }, + { + $addFields: { + score: { $meta: "textScore" }, + adminReason: { $cond: [showAdminReason, "$adminReason", "$$REMOVE"] } + } + }, + { + $match: { + "$or": [ + { score: { "$lt": lastOfferScore } }, + { score: lastOfferScore, [lastSortField]: { [sortFieldOperator]: lastSortValue } }, + { score: lastOfferScore, [lastSortField]: lastSortValue, _id: { "$gt": ObjectId(lastOfferId) } } + ] + } + }, { $match: Offer.filterCurrent() }, { $match: showHidden ? {} : Offer.filterNonHidden() } ]); } else { - offers = Offer.find({ "$and": [ - this._buildFilterQuery(filters), - { "$or": [ - { [lastSortField]: { [sortFieldOperator]: lastSortValue } }, - { [lastSortField]: lastSortValue, _id: { "$gt": ObjectId(lastOfferId) } } - ] } - ] }); + offers = Offer.find({ + "$and": [ + this._buildFilterQuery(filters), + { + "$or": [ + { [lastSortField]: { [sortFieldOperator]: lastSortValue } }, + { [lastSortField]: lastSortValue, _id: { "$gt": ObjectId(lastOfferId) } } + ] + } + ] + }); this.selectSearchOffers(offers, showHidden, showAdminReason); } @@ -336,10 +348,12 @@ class OfferService { { "$and": [ { jobMinDuration: { "$lt": jobMinDuration } }, - { "$or": [ - { jobMaxDuration: { "$exists": false } }, - { jobMaxDuration: { "$gte": jobMinDuration } }, - ] } + { + "$or": [ + { jobMaxDuration: { "$exists": false } }, + { jobMaxDuration: { "$gte": jobMinDuration } }, + ] + } ] }, ] @@ -353,17 +367,19 @@ class OfferService { { "$and": [ { jobMaxDuration: { "$gt": jobMaxDuration } }, - { "$or": [ - { jobMinDuration: { "$exists": false } }, - { jobMinDuration: { "$lte": jobMaxDuration } }, - ] } + { + "$or": [ + { jobMinDuration: { "$exists": false } }, + { jobMinDuration: { "$lte": jobMaxDuration } }, + ] + } ] }, ] }); } - if (fields?.length) constraints.push({ fields: { "$elemMatch": { "$in": fields } } }); - if (technologies?.length) constraints.push({ technologies: { "$elemMatch": { "$in": technologies } } }); + if (fields?.length) constraints.push({ fields: { "$elemMatch": { "$in": fields } } }); + if (technologies?.length) constraints.push({ technologies: { "$elemMatch": { "$in": technologies } } }); return constraints.length ? { "$and": constraints } : {}; }