How to set position dynamically in mongoose push

I didn’t find a mongoose way. But, here is a way I did it by passing index to the object property.

var i = "1";
var obj = { ["prop"+i+"Name"]: "response" };

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top