2

I am currently using RoboMongo to insert documents into my MongoDB collection. At times, I also need to make updates as well. My documents have two fields are causing me issues:

createdDate and updateDate

What I would like to do is provide the current Date and time stamp for when I make changes to the document, or when I insert a new document altogether. Inside RoboMongo, I'm trying to do the following:

{
     createdDate: new Date(),
     updatedDate: new Date(),
}

I have also tried replacing "new Date()" with "ISODate()" but when I try either option, I get an error from RoboMongo saying that I have a particular error on a particular line (which is where I am trying to call the Date()/ISODate() function.

How do I solve this issue?

syedfa
  • 2,801
  • 1
  • 41
  • 74
  • What error at least? What query you make? The only solution that comes to mind for "a particular error on a particular line" is "a particular fix". Also, what version of Robomongo. They are Robo3T for quite long time already. – Alex Blex Jun 22 '18 at 17:35
  • Thanks very much for responding. I'm using Robo 3T 1.1, and the specific error message I get is: "Unable to parse JSON: Expecting '}' or ',', at (9, 30)." – syedfa Jun 22 '18 at 18:04
  • 1
    Apparently the syntax of the query is wrong. Please update the question with reproducible query. – Alex Blex Jun 22 '18 at 19:11

1 Answers1

1

You can use $currentDate for getting current date time in mongo Db

You can follow example given in the documentation

Yatin Goyal
  • 322
  • 3
  • 10