I write 2 models in mongoose. first for Users another for Movies. I wrote this models below. first I save my all user in users collection. after that I want to save my movies to
Move the await findObjectIdByImdbId(obj.director) out of Movie initialization
E.g.
var directorObjId = await findObjectIdByImdbId(obj.director);
var movie = new Movie ({
imdbId: obj.id,
title: obj.name,
rank: obj.rank,
rating: obj.rating,
year: obj.year,
director: directorObjId
})