-
Notifications
You must be signed in to change notification settings - Fork 53
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
Dynamic Links\Reducers #437
Comments
To do this securely (i.e. not sending the real username of your business user to the client), you need to call the grapher query from a method. |
Thanks for responding @vparpoil I am already using two different methods, one for the The query in my initial question is the business query, how would I modify it to change the documents on the fly that do not match the Thanks. |
If you can access the userId of the user querying data inside the reducer, you can achieve what you want (ie: the reducer will compute a different value based on the user identity). Other way to deal with this would be to alter the results of the [Edit] Other answer : And some more context : Meteor.users.addReducers({
name: {
body: {
_id: 1,
profile: {
firstName: 1
}
},
reduce(object, params) {
if (isPublicUser(params.userId) && object._id !== params.userId){
return "Business"
}
return object.profile.firstName;
}
}
}); |
Thanks @vparpoil this worked and is exactly what I was looking for, very much appreciated! |
Thanks for this great package, it's been a life saver!
The title might be a little miss-leading, but here is the problem I have.
I have two collections,
Threads
andMessages
Threads
is basically a meta-data document that has information about themessages
Messages
has the actual data displayed to the user, and each message has auserId
field (important)When I retrieve the messages that belong to a thread, I have a link that looks like this:
I also have a reducer that looks like this:
Finally I have my query that looks like this:
Each thread and it's messages are accessible by 2 parties. The user who created the thread (public), and the business that the message was sent to. Everything works great except for one thing I would like to change.
When a business loads the messages, the app shows the names of everyone who created a message in the thread, public user and employees in the business.
This is the problem I am having here: When the user (public) loads the messages, I want the messages sent from the business to have the word
Business
instead of the user's real name's in the name field. Maybe a dynamicLink
orReducer
?Just for clarity:
Business should see:
javascript {text: 'message text here', name: {firstName: 'John'}
Public user should see:
javascript {text: 'message text here', name: {firstName: 'Business'}
NOT
javascript {text: 'message text here', name: {firstName: 'John'}
Is this something I can do easily with the grapher package?
Thanks.
The text was updated successfully, but these errors were encountered: