Mongoose find() returns undefined property and strange object

后端 未结 3 1810
庸人自扰
庸人自扰 2021-01-27 16:52

I have a bug that i can\'t resolve because for the first time it happen to me.

here is my query :

    Pack.find(
            {idclient: clientId }
               


        
3条回答
  •  隐瞒了意图╮
    2021-01-27 17:57

    As Told Model.find() generates an array so here is how I approach the situation:

    Kitten.find(function (err, kittens) {
        if (err) return console.error(err);
        kittens.forEach(function(kitten){
           console.log(kitten.name);
        }); 
    });
    

    This seems to me the most clear way to access the properties

提交回复
热议问题