hex7c0 / mongodb-restore

restore data from mongodb-backup for Nodejs
https://github.com/hex7c0/mongodb-restore
Apache License 2.0
53 stars 21 forks source link

Int64 _id gets parsed as a TimeStamp #8

Closed smlgbl closed 8 years ago

smlgbl commented 8 years ago

When exporting/backup-ing and subsequent restoring of documents with IDs like this:

"_id" : "1000576093407275579" (Int64)

they end up being transformed to this:

"_id" : Timestamp(1833010877, -705238994)

This is with the standard BSON parser. As a workaround I tried using the JSON parser, but that screws up all datatypes. This does not happen with the standard mongodump/mongorestore tools, but they're also using BSON as intermediate format.

smlgbl commented 8 years ago

Just realized, the error is already in the exported bson file. bsondump --type=debug says, the _id field is of type 1, which is Double, from the mongodump BSON file, but it's of type 17 (=TimeStamp) in the BSON file from mongodb-backup. Moving this issue to the other module....

hex7c0 commented 8 years ago

hi @smlgbl, I replicate your issue with abfb6350d68dd4658997130e4beb2b3e678d8ded commit you should update mongodb-restore to 1.5.x or change mongodb dependency to 1.5.x

       {
      -  "_bsontype": "Timestamp"
      +  "_bsontype": "Long"
       }