mongoose findById works when I use a string literal but not when I reference a property of an Object

后端 未结 1 1449
别跟我提以往
别跟我提以往 2021-01-22 12:56

I\'m having a really strange problem in Mongoose.

This line correctly finds the Round:

models.Round.findById(\"555ec731385b4d604356d8e5\", f         


        
相关标签:
1条回答
  • 2021-01-22 13:23

    If result is a JSON string, calling .round would return undefined.

    Try converting the JSON to a javascript object first:

    result = JSON.parse(result);
    models.Round.findById(result.round, function(err, roundref){
            console.log(roundref);
    
    0 讨论(0)
提交回复
热议问题