Custom Publications for non-database collections


#1

https://guide.meteor.com/data-loading.html#custom-publication describes a way to publish arbitrary data.

However, in both examples (the REST API example, and the generic custom pub example) it uses a COLLECTION_NAME or 'collection-name' in this.added

What if I don’t have a collection in a database? Hypothetical example (I realize for simple filters, there is a way to query the Users collection to do this instead):

I’ve got an Admin template, and I want to publish certain Users like so:

//inside the publish function
//userIdList is a preselected list of UserIds
//groupId is previously defined
var members =[];
            for(var i=0; i<userIdList.length; i++){
                var user = Meteor.users.findOne(userIdList[i]);
                var userInfo = {};
                userInfo._id=user._id;
                userInfo.email = user.emails[0].address;
                userInfo.roleList = Roles.getRolesForUser(userIdList[i], groupId);
                members.push(userInfo);
           }

How would I return members as a publication?
One issue is that roleList is an array of objects (usingalanning:Roles…so some sort of observeChanges is required, I think? Don’t really understand how to attach observeChanges to that in this scenario.
Thanks for any help!