What is the best way to use datetime in mongoDB

I am parsing the nginx log and want to save the date and time from my logs in mongodb. I store the date as a string (in this format yyyy-mm-dd) in my database, and my perl.What programming language is the best efficient way to store the date. Should I use the perl datetime module to format a date like this "date": "Sun Feb 13 2011 05:30:00 GMT + 0530 (IST)" "

I really want to understand what is the best way to save the date in mongodb. Please help me

+4
source share
1 answer

I believe that for logs it is better to use the history date as a date, but not as a string, because with a string you cannot query logs from one date to another (range). I believe that you will use range queries more than others.

+2
source

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


All Articles