Adding a transform function to Meteor.users?

153 views Asked by At

Some of my collections are declared like this

export default Foos = new Meteor.Collection('foo', {
  transform(foo) {
    foo.someMethod = someMethod;

    return foo;
  }
});

How do I apply a transformation function to the Meteor.users collection?


Update

My hack, currently, is to manually set it.

Meteor.users._transform = function (user) { ... return user; }

Seems to work.

1

There are 1 answers

1
kkkkkkk On

I see you already figured out how to add the transform function, but there is one more thing you should do. That is to wrap your function with LocalCollection.wrapTransform prior to assigning it to _transform:

Meteor.users._transform = LocalCollection.wrapTransform(function(user) { ... });

Doing this will make sure the returned objects contain the _id field so that subsystems can keep track of the objects identities. Also you need to add minimongo to your project to use this wrap function.