0
私のメッセージスキーマ:私は受信機とユーザをCONSOLE.LOGモンゴースのプロパティにアクセスできません。
const MessageSchema = new Schema({
conversationId: {
type: Schema.Types.ObjectId,
required: true
},
body: {
type: String,
required: true
},
seen: {
type: Boolean,
default: false,
},
sender: {
type: Schema.Types.ObjectId,
ref: 'userModel'
},
receiver: {
type: Schema.Types.ObjectId,
ref: 'userModel'
},
},
{
timestamps: true
});
が、それはオブジェクトを返し、それは次のようにあります:
await MessageModel.find({ conversationId: { $in: conversationIdsByUser } })
.populate({path:'receiver' ,options: { lean: true}})
.populate({path:'sender' ,options: { lean: true}})
.lean();
:これは私のクエリは
{ _id: 597f7eb1e5131d5a50e18d14,
updatedAt: 2017-07-31T19:02:09.035Z,
createdAt: 2017-07-31T19:02:09.035Z,
fullName: 'ria atayde',
email: '[email protected]',
password: '$2a$08$Kbkk69.8I9RQvTaRXy3nw.Oj.SEPhKPmhtI/ZWxIHyz2lgYiciVlC',
todos:
[ 597f801eab95955c1469bbfc,
597f8026ab95955c1469bbfd,
597f8030ab95955c1469bbfe ],
friendsIds: [ '597f7e3ce5131d5a50e18d13' ],
active: true,
__v: 0 }
です
私はすでにリーンを使用していますが、受信者と送信者のプロパティにはまだアクセスできません。 receiver._id?オブジェクトはそこにありますか?
デバッグのヘルプを求める質問(** "なぜこのコードは機能していないのですか?" **)は、質問自体に必要な動作、*特定の問題またはエラー、およびそれを再現するのに必要な最短コード* **。 **明確な問題文**のない質問は、他の読者には役に立たない。参照してください:[最小、完全、および検証可能な例を作成する方法](http://stackoverflow.com/help/mcve) –