#!/bin/bash
function getDeliveredDispatches(firstDateTime, lastDateTime, limit) {
var cursor = db.dispatches.find(
{$and: [
{"createdDtm" : {$gte : firstDateTime, $lte:lastDateTime}},
{"status.code" : {$in : ["DELIVERY_PENDING", "DELIVERY_SUCCESSFUL"]}}
]},
{"deliveryGroupId" : 1, "batchId": 1, "statusHistory.code" : 1}
);
var wrongDispatchesIds = [];
print("Number of dispatches selected based on filter = " + cursor.size())
while (cursor.hasNext()) {
var dispatch = cursor.next();
var index_generation_successfull = dispatch.statusHistory.map(function (status) {return status.code}).indexOf("GENERATION_SUCCESSFUL");
var index_delivery_pending = dispatch.statusHistory.map(function (status) {return status.code}).indexOf("DELIVERY_PENDING");
I have the below query which fetches some data from db. Whenever I am trying to execute it in bash I get: syntax error near unexpected token `firstDateTime,'
Kindly assist where am I going wrong. It would be a great help.