Friday 17 March 2017

Using mongodb with node to updateMany to ignore duplicates based on 500 json objects pulled via API

I've read the docs https://docs.mongodb.com/v3.2/reference/method/db.collection.updateMany/

I can't seem to pull API data from here https://api.gemini.com/v1/trades/btcusd?limit_trades=500&since=1444311607 and use updateMany to get it into the database.

I can pull the data and insert it just fine this way global.gemini_trades.insertMany(trades,function(err, r) {});

What I've tried:

global.gemini_trades.updateMany(trades,trades,{upsert:true},function(err, r) {});

Of course that didn't work because the first and second values are incorrect. I can't figure out how to insert 500 records and ignore duplicates.



via Branndon

No comments:

Post a Comment