1

I have the below sample code which is failing if i pass ISODate in JSON object

var data =[{"$match":{"CREATED_DATE":{"$gt":ISODate("2015-07-29T17:30:00.000Z"),"$lt":ISODate("2015-07-30T09:00:00.000Z")}}}]
var update=JSON.parse(data);

Below is the error

/home/ubuntu/rr.js:1
name) { var data =[{"$match":{"EPS_TRANSACTION.CREATED_DATE":{"$gt":ISODate("2
                                                                ^
ReferenceError: ISODate is not defined
at Object.<anonymous> (/home/ubuntu/rr.js:1:123)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3

I am unable to handle the error,any solution will be much helpful

stac
  • 19
  • 1
  • Based on the error message, ISODate doesn't exist. Try this instead http://stackoverflow.com/questions/15257911/create-an-iso-date-object-in-javascript – Coss Sep 10 '15 at 12:32
  • Why are you calling `JSON.parse` on an object? `JSON.parse` takes a string. – melpomene Sep 10 '15 at 13:28

0 Answers0