JavaScript In Meteor - how to do a bulk insert into a nested array meteor bulk insert,meteor mongodb bulk insert

I am trying to import several thousand records into a nested array in a collection in Meteor. This is financial data coming in a JSON object. I need to do some calculations on it before insertings it, so can't do that raw. Doing a $addToSet operation for every write is very, very slow. Is there a way to push the full set of data in one call?

My schema looks something like this.

NestedSchema = new SimpleSchema({
  item: {
    type: String
  },

   aThing: {
    type: Number
   }
});

MasterSchema = new SimpleSchema({
   symbol: {
     type: String,
     label: 'Symbol',
     unique: true
   },

   data: {
     type: [NestedSchema],
     optional: true
   }
});

I have a bunch of data like this that I want to insert.

var dataToInsert = [{item: "thing", aThing: 1}, {item: "thing2", aThing: 2}, {item: "thing3", aThing: 2}];

The data I'm trying to insert into the nested array is 5000+ records. I've looked at https://atmospherejs.com/udondan/bulk-collection-update and https://atmospherejs.com/mikowals/batch-insert but they don't seem to do exactly what I'm looking for. Ideally I would have a solution where I could append new records in bulk as I collect them.

Answer:1

I am working on one input application where i need to test input values that accepts single, multiple and even a range of numbers . Eg inputs : 70,900,80-20 // should return true as all are valid as,...

I am working on one input application where i need to test input values that accepts single, multiple and even a range of numbers . Eg inputs : 70,900,80-20 // should return true as all are valid as,...

  1. angular test input values

i created a crypto object as follows: var crypto = { encrypt: function(s) { } }; crypto.encrypt("cat"); I would get the following error Uncaught TypeError: crypto.encrypt is ...

i created a crypto object as follows: var crypto = { encrypt: function(s) { } }; crypto.encrypt("cat"); I would get the following error Uncaught TypeError: crypto.encrypt is ...

I try to run my test.js file below with the command: DEBUG=nightmare node --harmony test.js and taking output: nightmare queueing action "goto" for http://google.com +0ms nightmare queueing ...

I try to run my test.js file below with the command: DEBUG=nightmare node --harmony test.js and taking output: nightmare queueing action "goto" for http://google.com +0ms nightmare queueing ...

I want to take every element of from the API and show it in different classes. I am getting the result in my Console but not on the page. Please Help me out. Thanks you in Advance:) . I have used ...

I want to take every element of from the API and show it in different classes. I am getting the result in my Console but not on the page. Please Help me out. Thanks you in Advance:) . I have used ...