From df9a83c623a63ff5400db112a1201e6c9f800550 Mon Sep 17 00:00:00 2001
From: Sukhchain Brar <sukhchain@incomrealestate.com>
Date: Wed, 17 Jun 2020 11:28:59 -0400
Subject: [PATCH] #4

---
 includes/searchClass.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/includes/searchClass.js b/includes/searchClass.js
index 945c508..e674eeb 100644
--- a/includes/searchClass.js
+++ b/includes/searchClass.js
@@ -51,7 +51,7 @@ SearchClass.prototype.processFind = function(cursor, data, count, callback) {
   if (process.env.FILE_PROPERTY) {
     fileProperty = process.env.FILE_PROPERTY;
   }
-
+  
   if (data.sort) {
     cursor = cursor.sort(data.sort);
   }
@@ -62,7 +62,12 @@ SearchClass.prototype.processFind = function(cursor, data, count, callback) {
   if (data.skip) {
     cursor = cursor.skip(data.skip);
   }
-
+  if (data.executionLimit) {
+    cursor = cursor.maxTimeMS(data.executionLimit);
+  }
+  else if(process.env.MAX_TIME_MS){
+    cursor = cursor.maxTimeMS(process.env.MAX_TIME_MS);
+  }
   cursor.toArray(function(err, results) {
     if (err) {
       self.debug.debug('MongoClient:toArray err: %O', err);