0

it might look like a duplicate question but actually it is not.

I have a mongoDB database with some French towns in it (omelette du fromage), but the file from which I got those seems to have duplicate. At first I use this method to remove towns with the same name and it works just fine but then I learn some French towns localised in different parts of the country has the same name.

As they have zipCode we can legitimaly think about make the same operation on zipcodes, but zipcodes can be the same for two different cities. Kinda crooked. So I would like to use the same command but instead of only watching one property (the town's name or the zipcode), I would like to look at both of them. I am not that familiar with mongoDB and I'm using robomongo.

If anyone would be able to help me find out the solution and/or explain me how the first method works so I can get more in touch with mongo :) that would be awesome

enter image description here

EDIT:

It is not a duplicate of Remove duplicate in MongoDB (and if you pay attention you will see I even link this topic when I first asked my question). It was just a problem with the use in $group in mongoDB with two properties in order to achieve a former

db.pages.ensureIndex( { ville:1, codePost:1 }, { unique:true, dropDups:true } )
Community
  • 1
  • 1
Mowso
  • 113
  • 2
  • 14
  • Add the region also to the group step *{$group: {_id: {region: "$region", ville: "$ville"}}}* – joao Jun 23 '16 at 13:31
  • OOOH right. I tried it but I get a stupid syntax error. Eventually written like this it works just fine thank you. – Mowso Jun 23 '16 at 13:38
  • Possible duplicate of [Remove duplicate in MongoDB](http://stackoverflow.com/questions/35707496/remove-duplicate-in-mongodb) – profesor79 Jun 23 '16 at 14:05
  • @profesor79 Nah it's not. I just did not know how to use $group with two properties ^^ – Mowso Jun 24 '16 at 08:14

0 Answers0