Start a new topic

How to get user from custom endpoint to push him a notification

Hello!



My users have private (private read, private write) access to collection (events). I am using custom endpoint to insert new event for user (using its ID as record creator) and I want to push notification for this user.

modules.push.senMessage(user, 'NEW\_EVENT') requeres a user. Where should I get it?

I've tried modules.collectionAccess.collection('user').findOne({"\_id", "some user id"}, function (err, user)){} with no luck (no error, user = {})


_id is stored as a BSON object, you must convert the string "some user id" before querying it: {"_id", modules.collectionAccess.objectID("some user id")}
usernames are unique, you can search with request.username:

modules.collectionAccess.collection('user').findOne({"username": request.username}, function(err, user) {

if (!user) {

logger.fatal(request.username + ' not found');

response.complete(400);

} else {

...

}



If you use the user's _id for filtering, you have to convert it first (field is BSON):

query={"_id": modules.collectionAccess.objectID(request.body._id)}
Mike,



Try searching on "\_id" (note the underscore) or "\_acl.creator" . If those don't work buzz back and I'll try it on my end.



Justin
Login or Signup to post a comment