-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getFriends issue #5
Comments
Providing the friends array for the troublesome user document might be of use, here is what it contains - [
{
"_id" : ObjectId("534b8e5aaa5e7afc1b23e69b"),
"status" : "accepted",
"added" : ISODate("2015-01-28T03:42:17.348Z")
},
{
"_id" : ObjectId("54544cb2164ec1df2325dd99"),
"status" : "pending",
"added" : ISODate("2015-01-29T19:17:44.912Z")
},
{
"_id" : ObjectId("54c95b242ab6bc32636ad7b3"),
"status" : "pending",
"added" : ISODate("2015-01-30T03:27:39.021Z")
},
{
"_id" : ObjectId("54c581a6ed542a6c4a9f7ffd"),
"status" : "pending",
"added" : ISODate("2015-02-02T18:19:41.145Z")
}
] |
Ok so I was having a similar issue. Not sure if this fits your case, but here's what was happening for us: We have an onboarding process during registration to help users find/add friends that are already on the site. As part of the onboarding, we're re-saving the user document to track their progress. The problem is that when re-saving on each step, it was setting the So even though the user may have sent friend requests out on step 1, once they hit step 2 their account was re-saved with the empty array, leading to no records of sent requests on the current user, but still keeping the pending entries for the requested users, which will obviously cause issues. Ultimately it came down to the model instantiation in our signup route. Psuedo-code: app.post('/signup', function (req, res, next) {
var user = new User(values); // Here, user.friends is set to an empty array! So our client model received it as such, and then when re-saving from the client it was setting back to that empty array!
user.save(function (err, user) {
if (err) return next(err);
res.json(user);
});
}); The solution is just to set Hope that makes sense, and maybe helps you out. |
I've just faced the same problem. Updated mongoose module to 4.1.1 and it's gone |
Make sure your mongoose schema has the _id property with the right type:
this worked for me |
I haven't had time to investigate what is causing this issue for me but when calling the instance method
getFriends
on a document of my user model I am getting the following -My temporary fix is to continue the loop in the situation that
res.locals[res.friends[i]._id]
,friendship
, is undefined -below starts at 325 in plugin.js
Any ideas what could be causing this? It is strange because it only occurs on a few documents of my user model and I can't pinpoint why either.
This issue is occurring in your latest version published to NPM and also with the latest commit that removed the dependency on
underscore.js
.Thanks again for the awesome plugin.
The text was updated successfully, but these errors were encountered: