I'm trying to create a field modifiedBy with type: Object (to Meteor users).
I see you can setup blackbox: true for a Custom Object, but if I want to setup to a specific Object say a Group (collection) field modifiedBy is the logged in user, any pointers/help is greatly appreciated.
Thanks
As far as I see it, you have two options:
type: String
Denormalize it as you proposed
To denormalize it you can do something like this inside your schema:
As you pointed out, you'd want to update these properties when they change:
server-side
Store user-ids there with
type: String
I'd recommend storing user-ids. It's cleaner but it doesn't perform as well as the other solution. Here's how you could do that:
You could also easily write a
Custom Validator
for this. Now retrieving the Users is a bit more complicated. You could use a transform function to get the user objects.But there's a catch: "Transforms are not applied for the callbacks of observeChanges or to cursors returned from publish functions."
This means that to retrieve the doc reactively you'll have to write an abstraction: