Answer the question
In order to leave comments, you need to log in
RangeError: Maximum call stack size exceeded when saving multiple schemas in Mongoose?
Hello!
I am implementing a f-onal with the addition of a "friend" to the Mongoose schema. Here is the code on POST-route :
Router.route("/confirm_friend").post(function(req, res) {
UserSchema.findOne({ _id: req.body.self }).then(
(self) => {
UserSchema.findOne({ _id: req.body.whom }).then(
(whom) => {
self.friends.push(whom)
whom.friends.push(self);
self.requests.splice(self.requests.indexOf(whom), 1);
self.save();
whom.save();
res.send("success");
},
(err) => {
res.send(err);
console.log("--- err", err);
},
);
},
(err) => {
console.log("--- err", err);
},
);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question