0

how to convert model[i].bulkCreate(dtarr[i]); to map function?

        const dtarr = [dataItems.Container_Type];
        const model = [Container]

        for (var i=0; i < model.length; i++) {
            model[i].bulkCreate(dtarr[i]);
        }
myrul
  • 33
  • 5
  • Please correct code formatting, and add question. – tjeden Sep 25 '19 at 08:42
  • 1
    sorry for my formatting – myrul Sep 25 '19 at 08:49
  • 1
    Possible duplicate of [Index inside map() function](https://stackoverflow.com/questions/38364400/index-inside-map-function). I assume your problem is you don't know how to access the index of the collection you're iterating. Just use `.map((object, index) => object.bulkCreate(dtarr[index]))` –  Sep 25 '19 at 08:51

1 Answers1

1

You can use index argument of map function to get dtarr[index]

model.map((element, index) => element.bulkCreate(dtarr[index]));
Abito Prakash
  • 4,368
  • 2
  • 13
  • 26