Uploaded image for project: 'MongoDB Command Line Tools'
  1. MongoDB Command Line Tools
  2. TOOLS-69

MongoImport -- Support For Merge Imports

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.12, 3.3.14
    • Component/s: mongoimport
    • Labels:
      None
    • Documentation Changes:
      Needed

      Description

      Let's say I have a mongodb collection named customer where each record has this structure :

      { "_id" : 1, "name" : "Joe Smith", "addresses" : [

      { "address1" : "123 Rd", "city" : "LA"}

      ]}

      Let's also save I have a file of newline separated JSON's with the following structure:

      { "_id" : 1, "addresses" : [

      {"address1" : "123 Another Street", "city" : "LA"}

      ] }

      After a mongoimport --merge, I'd like the first record to become:

      { "_id" : 1, "name" : "Joe Smith", "addresses" : [

      {"address1" : "123 Another Street", "city" : "LA"}

      ] }

      In other words, name field is left untouched because not mentioned in the update, while addresses field is entirely replaced.

      The current behavior when using the --upsert option is to replace the entire record (in this example eliminating the name field entirely).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lucas.morales Lucas Morales
                Reporter:
                johnw John Walker
              • Votes:
                22 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: