Why after populate array of values is becoming null?Why is using “for…in” with array iteration a bad idea?Why is null an object and what's the difference between null and undefined?Sort array of objects by string property valueDetermine whether an array contains a valueCopy array by valueRemove duplicate values from JS arrayHow to achieve DBRef on virtualNodeJs, Mocha and MongooseWhy I can't retrieve any result when I use mongoose in my app
Does any lore text explain why the planes of Acheron, Gehenna, and Carceri are the alignment they are?
Metal bar on DMM PCB
X-shaped crossword
Convert camelCase and PascalCase to Title Case
Working in the USA for living expenses only; allowed on VWP?
Count down from 0 to 5 seconds and repeat
Do I include animal companions when calculating difficulty of an encounter?
What are the words for people who cause trouble believing they know better?
What flavor of zksnark in tezos
How do you build a story from a world?
What makes linear regression with polynomial features curvy?
I wrote a scene that the majority of my readers loved. How do I get back to that place while writing my new book?
Why do guitarists wave their guitars?
Linux tr to convert vertical text to horizontal
How to split a string in two substrings of same length using bash?
What is the right way to float a home lab?
Movie where a boy is transported into the future by an alien spaceship
Did thousands of women die every year due to illegal abortions before Roe v. Wade?
Word for a small burst of laughter that can't be held back
correct term describing the action of sending a brand-new ship out into its first seafaring trip
Could the Missouri River be running while Lake Michigan was frozen several meters deep?
Riley's, assemble!
What are the words for people who cause trouble believing they know better?
What do we gain with higher order logics?
Why after populate array of values is becoming null?
Why is using “for…in” with array iteration a bad idea?Why is null an object and what's the difference between null and undefined?Sort array of objects by string property valueDetermine whether an array contains a valueCopy array by valueRemove duplicate values from JS arrayHow to achieve DBRef on virtualNodeJs, Mocha and MongooseWhy I can't retrieve any result when I use mongoose in my app
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I want to populate answers(comments) on my post . But on populating it becomes null while before that it stores fine of storing Id's of answer.
My schema of post
var doubtsSchema = new mongoose.Schema(
title : String,
content : String,
tags : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose.Schema.Types.ObjectId,
ref : "User",
username : String,
answers : [
type : mongoose.Schema.Types.ObjectId,
ref : "Answers"]);
module.exports = mongoose.model("Doubts",doubtsSchema);
My schema of answer
var answersSchema = new mongoose.Schema(
content : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose .Schema .Types . ObjectId,
ref : "User",
username : String,
likes_count : Number);
module.exports = mongoose.model("Answers",answersSchema);
Populate is not working
Doubts.findById(req.params.id).populate('answers').exec(function(err,foundDoubt)
if(err)
console.log(err);
else
console.log("here");
console.log(foundDoubt);
res.render("doubts/show",doubt : foundDoubt);
);
javascript node.js mongodb
add a comment |
I want to populate answers(comments) on my post . But on populating it becomes null while before that it stores fine of storing Id's of answer.
My schema of post
var doubtsSchema = new mongoose.Schema(
title : String,
content : String,
tags : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose.Schema.Types.ObjectId,
ref : "User",
username : String,
answers : [
type : mongoose.Schema.Types.ObjectId,
ref : "Answers"]);
module.exports = mongoose.model("Doubts",doubtsSchema);
My schema of answer
var answersSchema = new mongoose.Schema(
content : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose .Schema .Types . ObjectId,
ref : "User",
username : String,
likes_count : Number);
module.exports = mongoose.model("Answers",answersSchema);
Populate is not working
Doubts.findById(req.params.id).populate('answers').exec(function(err,foundDoubt)
if(err)
console.log(err);
else
console.log("here");
console.log(foundDoubt);
res.render("doubts/show",doubt : foundDoubt);
);
javascript node.js mongodb
mongoosejs.com/docs/populate.html#refs-to-childrenThere are two perspectives here. First, you may want the author know which stories are theirs. Usually, your schema should resolve one-to-many relationships by having a parent pointer in the 'many' side. But, if you have a good reason to want an array of child pointers, you can push() documents onto the array as shown below.
– Nikita Umnov
Mar 24 at 13:53
@NikitaUmnov Thankyou for your help. But can you please tell me what should i do now ,because it's not working. Should i write brute code to populate?
– Zing
Mar 24 at 14:53
If in doubt you can edit your question to include a document from yourdoubts
collection and theanswers
documents you believe to be related which are showing up asnull
. What you will likely find though is that the_id
values in theanswers
collection do not match up with those in theanswers
array of the parent document, since your code has likely managed to insert different values or possibly never saved theanswers
documents at all. So it's the "creation code" and not the "population code" this is the problem here. Show that code if you do not spot the problem.
– Neil Lunn
Mar 24 at 18:39
@NeilLunn when i checked out the database, the "answers" of doubtSchema is containing the ObjectId of answers . The only problem arises when I'm using the "populate('answers')" . It then nullifies the answers of doubtSchema.
– Zing
Mar 25 at 5:34
What you were actually asked to do is "show the documents". If you think the data is correct, then by all means "show it". Then someone can actually use that same data to either reproduce the problem, or not. With the latter case really only being able to show an example which may do something differently, than other code you have not included in the question. But you really need to *show the data" first.
– Neil Lunn
Mar 25 at 6:45
add a comment |
I want to populate answers(comments) on my post . But on populating it becomes null while before that it stores fine of storing Id's of answer.
My schema of post
var doubtsSchema = new mongoose.Schema(
title : String,
content : String,
tags : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose.Schema.Types.ObjectId,
ref : "User",
username : String,
answers : [
type : mongoose.Schema.Types.ObjectId,
ref : "Answers"]);
module.exports = mongoose.model("Doubts",doubtsSchema);
My schema of answer
var answersSchema = new mongoose.Schema(
content : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose .Schema .Types . ObjectId,
ref : "User",
username : String,
likes_count : Number);
module.exports = mongoose.model("Answers",answersSchema);
Populate is not working
Doubts.findById(req.params.id).populate('answers').exec(function(err,foundDoubt)
if(err)
console.log(err);
else
console.log("here");
console.log(foundDoubt);
res.render("doubts/show",doubt : foundDoubt);
);
javascript node.js mongodb
I want to populate answers(comments) on my post . But on populating it becomes null while before that it stores fine of storing Id's of answer.
My schema of post
var doubtsSchema = new mongoose.Schema(
title : String,
content : String,
tags : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose.Schema.Types.ObjectId,
ref : "User",
username : String,
answers : [
type : mongoose.Schema.Types.ObjectId,
ref : "Answers"]);
module.exports = mongoose.model("Doubts",doubtsSchema);
My schema of answer
var answersSchema = new mongoose.Schema(
content : String,
created :
type : Date,
default : Date.now,
author :
id :
type : mongoose .Schema .Types . ObjectId,
ref : "User",
username : String,
likes_count : Number);
module.exports = mongoose.model("Answers",answersSchema);
Populate is not working
Doubts.findById(req.params.id).populate('answers').exec(function(err,foundDoubt)
if(err)
console.log(err);
else
console.log("here");
console.log(foundDoubt);
res.render("doubts/show",doubt : foundDoubt);
);
javascript node.js mongodb
javascript node.js mongodb
edited Mar 24 at 14:56
F.G.
1048
1048
asked Mar 24 at 13:36
ZingZing
113
113
mongoosejs.com/docs/populate.html#refs-to-childrenThere are two perspectives here. First, you may want the author know which stories are theirs. Usually, your schema should resolve one-to-many relationships by having a parent pointer in the 'many' side. But, if you have a good reason to want an array of child pointers, you can push() documents onto the array as shown below.
– Nikita Umnov
Mar 24 at 13:53
@NikitaUmnov Thankyou for your help. But can you please tell me what should i do now ,because it's not working. Should i write brute code to populate?
– Zing
Mar 24 at 14:53
If in doubt you can edit your question to include a document from yourdoubts
collection and theanswers
documents you believe to be related which are showing up asnull
. What you will likely find though is that the_id
values in theanswers
collection do not match up with those in theanswers
array of the parent document, since your code has likely managed to insert different values or possibly never saved theanswers
documents at all. So it's the "creation code" and not the "population code" this is the problem here. Show that code if you do not spot the problem.
– Neil Lunn
Mar 24 at 18:39
@NeilLunn when i checked out the database, the "answers" of doubtSchema is containing the ObjectId of answers . The only problem arises when I'm using the "populate('answers')" . It then nullifies the answers of doubtSchema.
– Zing
Mar 25 at 5:34
What you were actually asked to do is "show the documents". If you think the data is correct, then by all means "show it". Then someone can actually use that same data to either reproduce the problem, or not. With the latter case really only being able to show an example which may do something differently, than other code you have not included in the question. But you really need to *show the data" first.
– Neil Lunn
Mar 25 at 6:45
add a comment |
mongoosejs.com/docs/populate.html#refs-to-childrenThere are two perspectives here. First, you may want the author know which stories are theirs. Usually, your schema should resolve one-to-many relationships by having a parent pointer in the 'many' side. But, if you have a good reason to want an array of child pointers, you can push() documents onto the array as shown below.
– Nikita Umnov
Mar 24 at 13:53
@NikitaUmnov Thankyou for your help. But can you please tell me what should i do now ,because it's not working. Should i write brute code to populate?
– Zing
Mar 24 at 14:53
If in doubt you can edit your question to include a document from yourdoubts
collection and theanswers
documents you believe to be related which are showing up asnull
. What you will likely find though is that the_id
values in theanswers
collection do not match up with those in theanswers
array of the parent document, since your code has likely managed to insert different values or possibly never saved theanswers
documents at all. So it's the "creation code" and not the "population code" this is the problem here. Show that code if you do not spot the problem.
– Neil Lunn
Mar 24 at 18:39
@NeilLunn when i checked out the database, the "answers" of doubtSchema is containing the ObjectId of answers . The only problem arises when I'm using the "populate('answers')" . It then nullifies the answers of doubtSchema.
– Zing
Mar 25 at 5:34
What you were actually asked to do is "show the documents". If you think the data is correct, then by all means "show it". Then someone can actually use that same data to either reproduce the problem, or not. With the latter case really only being able to show an example which may do something differently, than other code you have not included in the question. But you really need to *show the data" first.
– Neil Lunn
Mar 25 at 6:45
mongoosejs.com/docs/populate.html#refs-to-children
There are two perspectives here. First, you may want the author know which stories are theirs. Usually, your schema should resolve one-to-many relationships by having a parent pointer in the 'many' side. But, if you have a good reason to want an array of child pointers, you can push() documents onto the array as shown below.
– Nikita Umnov
Mar 24 at 13:53
mongoosejs.com/docs/populate.html#refs-to-children
There are two perspectives here. First, you may want the author know which stories are theirs. Usually, your schema should resolve one-to-many relationships by having a parent pointer in the 'many' side. But, if you have a good reason to want an array of child pointers, you can push() documents onto the array as shown below.
– Nikita Umnov
Mar 24 at 13:53
@NikitaUmnov Thankyou for your help. But can you please tell me what should i do now ,because it's not working. Should i write brute code to populate?
– Zing
Mar 24 at 14:53
@NikitaUmnov Thankyou for your help. But can you please tell me what should i do now ,because it's not working. Should i write brute code to populate?
– Zing
Mar 24 at 14:53
If in doubt you can edit your question to include a document from your
doubts
collection and the answers
documents you believe to be related which are showing up as null
. What you will likely find though is that the _id
values in the answers
collection do not match up with those in the answers
array of the parent document, since your code has likely managed to insert different values or possibly never saved the answers
documents at all. So it's the "creation code" and not the "population code" this is the problem here. Show that code if you do not spot the problem.– Neil Lunn
Mar 24 at 18:39
If in doubt you can edit your question to include a document from your
doubts
collection and the answers
documents you believe to be related which are showing up as null
. What you will likely find though is that the _id
values in the answers
collection do not match up with those in the answers
array of the parent document, since your code has likely managed to insert different values or possibly never saved the answers
documents at all. So it's the "creation code" and not the "population code" this is the problem here. Show that code if you do not spot the problem.– Neil Lunn
Mar 24 at 18:39
@NeilLunn when i checked out the database, the "answers" of doubtSchema is containing the ObjectId of answers . The only problem arises when I'm using the "populate('answers')" . It then nullifies the answers of doubtSchema.
– Zing
Mar 25 at 5:34
@NeilLunn when i checked out the database, the "answers" of doubtSchema is containing the ObjectId of answers . The only problem arises when I'm using the "populate('answers')" . It then nullifies the answers of doubtSchema.
– Zing
Mar 25 at 5:34
What you were actually asked to do is "show the documents". If you think the data is correct, then by all means "show it". Then someone can actually use that same data to either reproduce the problem, or not. With the latter case really only being able to show an example which may do something differently, than other code you have not included in the question. But you really need to *show the data" first.
– Neil Lunn
Mar 25 at 6:45
What you were actually asked to do is "show the documents". If you think the data is correct, then by all means "show it". Then someone can actually use that same data to either reproduce the problem, or not. With the latter case really only being able to show an example which may do something differently, than other code you have not included in the question. But you really need to *show the data" first.
– Neil Lunn
Mar 25 at 6:45
add a comment |
1 Answer
1
active
oldest
votes
I made a simple example, it works
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/test", useNewUrlParser: true);
const UserSchema = new mongoose.Schema(
name: String,
comments: [type: mongoose.Schema.Types.ObjectId, ref: "Comments"]
);
const CommentSchema = new mongoose.Schema(
content: ""
);
const Users = mongoose.model("Users", UserSchema);
const Comments = mongoose.model("Comments", CommentSchema);
// Adding data
Promise.all([
new Comments(content: "test 1").save(),
new Comments(content: "test 2").save(),
new Comments(content: "test 3").save()
]).then(result =>
result = result.map(r => r._id);
new Users(name: "test", comments: result).save().then(user =>
// Getting with populate
Users.findById(user._id).populate("comments").then(console.log);
)
).catch(console.error);
In console:
comments:
[ _id: 5c979d9dedc0b1db90fe81dd, content: 'test 1', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81de, content: 'test 2', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81df, content: 'test 3', __v: 0 ],
_id: 5c979d9dedc0b1db90fe81e0,
name: 'test',
__v: 0
Maybe it will help to find the error
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324367%2fwhy-after-populate-array-of-values-is-becoming-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I made a simple example, it works
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/test", useNewUrlParser: true);
const UserSchema = new mongoose.Schema(
name: String,
comments: [type: mongoose.Schema.Types.ObjectId, ref: "Comments"]
);
const CommentSchema = new mongoose.Schema(
content: ""
);
const Users = mongoose.model("Users", UserSchema);
const Comments = mongoose.model("Comments", CommentSchema);
// Adding data
Promise.all([
new Comments(content: "test 1").save(),
new Comments(content: "test 2").save(),
new Comments(content: "test 3").save()
]).then(result =>
result = result.map(r => r._id);
new Users(name: "test", comments: result).save().then(user =>
// Getting with populate
Users.findById(user._id).populate("comments").then(console.log);
)
).catch(console.error);
In console:
comments:
[ _id: 5c979d9dedc0b1db90fe81dd, content: 'test 1', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81de, content: 'test 2', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81df, content: 'test 3', __v: 0 ],
_id: 5c979d9dedc0b1db90fe81e0,
name: 'test',
__v: 0
Maybe it will help to find the error
add a comment |
I made a simple example, it works
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/test", useNewUrlParser: true);
const UserSchema = new mongoose.Schema(
name: String,
comments: [type: mongoose.Schema.Types.ObjectId, ref: "Comments"]
);
const CommentSchema = new mongoose.Schema(
content: ""
);
const Users = mongoose.model("Users", UserSchema);
const Comments = mongoose.model("Comments", CommentSchema);
// Adding data
Promise.all([
new Comments(content: "test 1").save(),
new Comments(content: "test 2").save(),
new Comments(content: "test 3").save()
]).then(result =>
result = result.map(r => r._id);
new Users(name: "test", comments: result).save().then(user =>
// Getting with populate
Users.findById(user._id).populate("comments").then(console.log);
)
).catch(console.error);
In console:
comments:
[ _id: 5c979d9dedc0b1db90fe81dd, content: 'test 1', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81de, content: 'test 2', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81df, content: 'test 3', __v: 0 ],
_id: 5c979d9dedc0b1db90fe81e0,
name: 'test',
__v: 0
Maybe it will help to find the error
add a comment |
I made a simple example, it works
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/test", useNewUrlParser: true);
const UserSchema = new mongoose.Schema(
name: String,
comments: [type: mongoose.Schema.Types.ObjectId, ref: "Comments"]
);
const CommentSchema = new mongoose.Schema(
content: ""
);
const Users = mongoose.model("Users", UserSchema);
const Comments = mongoose.model("Comments", CommentSchema);
// Adding data
Promise.all([
new Comments(content: "test 1").save(),
new Comments(content: "test 2").save(),
new Comments(content: "test 3").save()
]).then(result =>
result = result.map(r => r._id);
new Users(name: "test", comments: result).save().then(user =>
// Getting with populate
Users.findById(user._id).populate("comments").then(console.log);
)
).catch(console.error);
In console:
comments:
[ _id: 5c979d9dedc0b1db90fe81dd, content: 'test 1', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81de, content: 'test 2', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81df, content: 'test 3', __v: 0 ],
_id: 5c979d9dedc0b1db90fe81e0,
name: 'test',
__v: 0
Maybe it will help to find the error
I made a simple example, it works
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/test", useNewUrlParser: true);
const UserSchema = new mongoose.Schema(
name: String,
comments: [type: mongoose.Schema.Types.ObjectId, ref: "Comments"]
);
const CommentSchema = new mongoose.Schema(
content: ""
);
const Users = mongoose.model("Users", UserSchema);
const Comments = mongoose.model("Comments", CommentSchema);
// Adding data
Promise.all([
new Comments(content: "test 1").save(),
new Comments(content: "test 2").save(),
new Comments(content: "test 3").save()
]).then(result =>
result = result.map(r => r._id);
new Users(name: "test", comments: result).save().then(user =>
// Getting with populate
Users.findById(user._id).populate("comments").then(console.log);
)
).catch(console.error);
In console:
comments:
[ _id: 5c979d9dedc0b1db90fe81dd, content: 'test 1', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81de, content: 'test 2', __v: 0 ,
_id: 5c979d9dedc0b1db90fe81df, content: 'test 3', __v: 0 ],
_id: 5c979d9dedc0b1db90fe81e0,
name: 'test',
__v: 0
Maybe it will help to find the error
answered Mar 24 at 15:12
Nikita UmnovNikita Umnov
867
867
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324367%2fwhy-after-populate-array-of-values-is-becoming-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
mongoosejs.com/docs/populate.html#refs-to-children
There are two perspectives here. First, you may want the author know which stories are theirs. Usually, your schema should resolve one-to-many relationships by having a parent pointer in the 'many' side. But, if you have a good reason to want an array of child pointers, you can push() documents onto the array as shown below.
– Nikita Umnov
Mar 24 at 13:53
@NikitaUmnov Thankyou for your help. But can you please tell me what should i do now ,because it's not working. Should i write brute code to populate?
– Zing
Mar 24 at 14:53
If in doubt you can edit your question to include a document from your
doubts
collection and theanswers
documents you believe to be related which are showing up asnull
. What you will likely find though is that the_id
values in theanswers
collection do not match up with those in theanswers
array of the parent document, since your code has likely managed to insert different values or possibly never saved theanswers
documents at all. So it's the "creation code" and not the "population code" this is the problem here. Show that code if you do not spot the problem.– Neil Lunn
Mar 24 at 18:39
@NeilLunn when i checked out the database, the "answers" of doubtSchema is containing the ObjectId of answers . The only problem arises when I'm using the "populate('answers')" . It then nullifies the answers of doubtSchema.
– Zing
Mar 25 at 5:34
What you were actually asked to do is "show the documents". If you think the data is correct, then by all means "show it". Then someone can actually use that same data to either reproduce the problem, or not. With the latter case really only being able to show an example which may do something differently, than other code you have not included in the question. But you really need to *show the data" first.
– Neil Lunn
Mar 25 at 6:45