javascript - Can't backfill array to larger than 1500000 elements -


i have mongodb document named collection:

{     _id: objectid('53e9dd54c784717558c46997'),     bloks: [ /* subdocument array */ ],     sections: [ /* subdocument array */ ],     chapters: [ /* subdocument array */ ] }  

and each of subdocuments have id , state fields strings among other fields.

when using mongoose, can update bloks , return collection using:

update = { bloks: [ /*some changed array*/ ] };  collection.findbyidandupdate(collection._id, update, function (err, collection) {     if (err) {         // return error     } else {        // return collection     } }); 

but when try update specific section , chapter state in other arrays:

update = {      bloks: [ /*some changed array*/ ],     'sections.140439739188823467.state': 'some state',     'chapters.1404397391757313579.state': 'some state' }; 

i error:

can't backfill array larger 1500000 elements 

how can update collection document bloks, sections , chapters data , have it's current value?

please note, i'm using .findbyidandupdate() because more efficient , had problems making .update() method actual save.

thanks leonid beschastny comment in question, figured out using subdocuments ids indices in arrays, modifed code figure out correct ones.

    sindex = _.findindex(collection.sections, function (section) {         return sid === section.id;     });      if (-1 < sindex) {         update['sections.' + sindex + '.state'] = 'state';     }        hindex = _.findindex(collection.chapters, function (chapter) {         return hid === chapter.id;     });     if (-1 < hindex) {         update['chapters.' + hindex + '.state'] = 'state';     } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -