Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

Mongoose Populated Document not visible in MongoDB Compass

I have put together a reference model, a profile has one user (logon user). I am able to associate the User to the Profile when I create the user by passing in the User ObjectId.

Then, when I "populate" the Collection on the reference field (e.g. userRef), MongoDB Compass does not show the document. MongoDB Compass still shows the User ObjectID template type.

However, I can access the reference object from vsCode. For example, I log out the value of Profile.userRef on the instance of the Profile model, it returns the correct UserRef doc. It is just not visible in Compass...

Anyone come across this before?

db.ProfileModel.findOne({ profileType: "Cadet" })
  .populate({
    path: "userRef",
    model: "User",
  })
  .exec(function (err, profile) {
    if (err) return handleError(err);
    console.log(profile.userRef);
  });
question from:https://stackoverflow.com/questions/65854049/mongoose-populated-document-not-visible-in-mongodb-compass

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...