Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5543

mongoimport should support ISODate() format for import

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.1.0
    • Component/s: Tools
    • None

      Problem:
      mongoimport does not support JSON with the ISODate representation, for example

      { "_id" : ObjectId("4e5bb37258200ed9aabc5d67"), "name" : "Bob", "age" : 28, "address" : "123 fake street", "ts" : ISODate("2010-09-28T13:07:12Z") }

      It will fail with the following error

      Mon Apr 9 09:06:09 Assertion: 10340:Failure parsing JSON string near: , "ts" : I

      Solution:
      Extend monogimport to support ISODate

      Test case:

      > db.foo.save(

      {name:"bob", ts: ISODate("2012-04-09")}

      );

      > db.foo.find(

      {name:"bob"}

      );

      { "_id" : ObjectId("4f82992047a6783d6427f207"), "name" : "bob", "ts" : ISODate("2012-04-09T00:00:00Z") }

      > exit

      cut & paste that object into a file , e.g. tmp/3/json

      $ mongoimport -d test -c foo /tmp/3.json

            Assignee:
            Unassigned Unassigned
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: