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

MongoImport -- Support For Merge Imports

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.12, 3.3.14
    • Affects Version/s: None
    • Component/s: mongoimport
    • None
    • Needed

      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).

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

              Created:
              Updated:
              Resolved: