GetStream/stream-node-orm

Ability to restrict attributes when enriching activities

etorrejon opened this issue · 4 comments

Problem: Not all attributes are needed when enriching activities. In some cases, it's desirable to hide values (e.g. e-mail address, hashed passwords, other secrets). Calling StreamBackend.enrichActivities appears to return all attributes for each document found.

It would be great to be able to define a projection, or some other spec to define which attributes will be included or excluded on a per-model/schema basis.

It seems that this is a common use-case. Suggestions/ideas on solutions to this problem would be much appreciated.

Thanks in advance!

What would your suggestion be on letting this work. Would you define properties to be ignored on your schema, or do you want to define properties to be included. And do you know if Mongoose has API's for this 'hiding' process (I must admit I am not super familiar with the Mongoose API).

Hi Matthisk, thanks for your response!

The ability to somehow decorate an attribute in a Mongoose schema could be one approach. Perhaps the ability to register a projection or field definition/whitelist for each model that needs to be enriched would also be useful. It may be a bit cumbersome, but I can imagine that this is a common use case.

The only other idea I have is to suggest following a convention of hiding attributes in your schema using the Mongoose select: false option, which is basically what I've done to work around the problem.

it's now possible to overwrite the behaviour (since 1.4.0). so you can disable certain references, or read the data from cache instead of the ORM etc.

@tschellenbach
Sorry to be opening this thread again. But when you say:

it's now possible to overwrite the behaviour (since 1.4.0). so you can disable certain references, or read the data from cache instead of the ORM etc.

How can I do that? I need to hide plenty of data from the user when I enrich the activity.

Thanks