Mongodb: Compare two collections and eliminate repeated documents

0

I work in a company that makes the collection service to bank customers (banks are our clients) and I mention this so that I do not think I do it for non-legal purposes.

What is the best mechanism to eliminate existing data in another collection?

We are developing a collection system in which it is necessary to import a good amount of customer accounts into a temporary collection (We can import up to 100 thousand records per import, and this process can be daily). The problem is that in this temporary collection there is customer data that is already registered in another collection (Permanent).

What is the ideal mechanism for importing all those accounts and comparing them (for your identity document) with existing customer documents in another collection?

I found this link but I'm not sure that is able to find differences in so many records

    
asked by Ricky 03.10.2017 в 01:00
source

1 answer

1

For my purposes, the method bulk.insert () from Mongodb Solve my problem. How does it work? How did I do it?

  • I prepared my collection by defining a unique index.
  • I used the bulk insert method and prepared it in the following way:

    bulk.insert ({     client_id: line [0],     iddoi: line [1],     id_personality: line [2],     liente: line [3] });

  • I created these types of objects using a for loop, where I added all the elements to be inserted.
  • Completed the inclusion I used bulk.execute ().
  • That was enough. This method is to enter only those that are not repeated, it is not necessary to make the comparison, extract those that are not repeated and insert the records. Super savings.

    For the one who serves him.

        
    answered by 03.10.2017 / 22:08
    source