Which MongoDB types are not preserved by mongoimport/mongoexport?

前端 未结 1 1371
名媛妹妹
名媛妹妹 2021-01-16 00:25

The documentation for mongoexport has this scary warning,

Avoid using mongoimport and mongoexport for full instance production backups. They do not re

1条回答
  •  被撕碎了的回忆
    2021-01-16 01:01

    Turns out that the warning against mongoimport/export is obsolete. It's still a good idea to use mongodump/restore for speed, but mongoexport preserves type information using the MongoDB Extended JSON format. For example, a Date field is no longer silently converted to text, but instead to:

    { "$date": "" }
    

    where is the ISO-8601 YYYY-MM-DDTHH:mm:ss.mmm<+/-Offset> representation of the date. Regular expressions are converted to

    { "$regex": "", "$options": "" }
    

    etc. These textual representation of the document fields are parsed by mongoimport, restoring the original types. See BSON Data Types and Associated Representations for more information.

    The warning will hopefully be removed soon.

    0 讨论(0)
提交回复
热议问题