0

From my research I have only found solutions that either:

Are outdated - and db.runCommand do not work in node.js as below link:

Can't get to work within node.js

Don't list all sub/nested keys (see problem in answer)

I also wonder if it possible to now do with the Aggregation Framework...?

Seems to be quite a known feature missing from MongoDB...

Any help much appreciated, thanks!

ssmith
  • 1
  • 2
  • What is the problem here? Can you add some details to that? – Akarsh Satija Aug 09 '17 at 10:31
  • Nothing outdated about it. Even the latest release cannot do anything more than list the top level keys only. The correct solution is **still** to use `mapReduce()`. It's also not a "feature" with as much utility as you seem to think it has. – Neil Lunn Aug 09 '17 at 10:31
  • And perhaps you might try [reading the documentation](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#mapReduce). – Neil Lunn Aug 09 '17 at 10:35
  • db.runCommand does not work on node.js – ssmith Aug 09 '17 at 10:40
  • Also, as discussed here: https://stackoverflow.com/questions/35335469/run-map-reduce-for-all-keys-in-collections-mongodb The aggregation framework may be faster...? – ssmith Aug 09 '17 at 10:45
  • Why do you need `runCommand` if there's a native [`mapReduce`](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#mapReduce) method available in the driver? – robertklep Aug 09 '17 at 10:49
  • becuase when i try with: result = db.COLLECTION.mapReduce( I get a type error: cannot read property 'mapReduce' of undefined – ssmith Aug 09 '17 at 10:52
  • Please look specifically at the example code for `mapReduce` to find out why that won't work. – robertklep Aug 09 '17 at 10:57
  • Now I just get: cannot read property result of undefined. I could post my code but it doesnt format correctly in comments i dont think... I have tried combining the example you linked to and the marked duplicate solution. Maybe its dto do with mapreduce not returning the result globally? I dont know :L – ssmith Aug 09 '17 at 11:20
  • I also needed to include the "out" part which was not in the original solution something like this: mr = coll.mapReduce(map,reduce,{out: {inline:1},verbose:true}) – ssmith Aug 09 '17 at 11:22

0 Answers0