Import date (ISODate) into MongoDB using mongoimport

I have this MongoDB document. In JSON:

{ "attString":"hello World0", "attInt":0, "attDate":new Date("1990-7-20") } 

How to import this document into MongoDB using mongoimport ? I have a problem with the attDate field.

This is the MongoDB shell notification:

Error: Token cancellation error in file # 1: unexpected ISODate format

+5
source share
1 answer

You must change your date format in JSON

Or

 {"attString":"hello World0","attInt":0,"attDate":ISODate("2013-11-20T23:32:18Z")} 

OR

 {"attString":"hello World0","attInt":0,"attDate":{$date:"2013-11-20T23:32:18Z"}} 

Hope this helps

+12
source

Source: https://habr.com/ru/post/1233634/


All Articles