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]);
        }
3
  • Please correct code formatting, and add question. Commented Sep 25, 2019 at 8:42
  • 1
    sorry for my formatting Commented Sep 25, 2019 at 8:49
  • 1
    Possible duplicate of 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])) Commented Sep 25, 2019 at 8:51

1 Answer 1

1

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

model.map((element, index) => element.bulkCreate(dtarr[index]));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.