Here's an example of my docs:
[{name:"duplicate", value:true, id:2910921},{name:"duplicate", value:true, id:32838293},{name:"duplicate", value:false, id:3283232},{name:"notDuplicate", value:true, id:382932}]
I want to remove if there are multiple documents that contain the same name and the same value. In the example above it would remove one document, either {name:"duplicate", value:true, id:2910921} or {name:"duplicate", value:true, id:32838293}, it does't matter to me which one.
So far, I've considered just creating a new field for each of these which would be something like newField: "duplicatetrue" and then I could just use distinct on these to remove dupes, but I am having trouble figuring out how to concat two different fields with different types into a new field. I'm definitely open to better suggestions as well. Here's what I have so far:
db.collection(collectionName).updateMany({}, {$set: {"newField": ["$name","$value"] }})
However, the above line doesn't output the values, rather it outputs exactly newField: ["$name","$value"]
Removing the quotes from $name and $value does not work either.
I'm using the Node mongodb driver: 3.5.8