Answer the question
In order to leave comments, you need to log in
Why is mongo not adding entries to the collection correctly?
Good day.
There is a comment schema:
var commentSchema = mongoose.Schema({
text: String,
postNum: Number,
num: Number,
rating: [],
addtime: String,
to: Number
});
Comment.count({}, function (err, count) {
var newComment = new Comment;
newComment.text = comment;
newComment.authorId = authorId;
newComment.num = count + 1;
newComment.postNum = postNum;
newComment.save(function (err) {
if(err) throw err;
.....
});
Answer the question
In order to leave comments, you need to log in
Did not create indexes on fields? when creating, you can specify storage sorting, I don’t know for sure whether this affects the selection without using this field. And so I advise you not to focus on the order of insertion, but to use the usual "sort" tool to specify exactly in which order to show.
You can also try directly, through the console, to make a request, if it returns correctly, then the interface is stupid.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question