how to use of objectId in nodejs

前端 未结 1 531
渐次进展
渐次进展 2021-01-25 11:53

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

相关标签:
1条回答
  • 2021-01-25 12:32

    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
    })
    
    0 讨论(0)
提交回复
热议问题