So I have the following publish method that creates a Room with many parameters:
Meteor.publish('addRoom', function publishFunction(options, admin, adminKey, members, roomName, isOpen, finalChoice, timeStamp) {
//add relevant info to collection
Rooms.insert({
optionsList: options,
optionsArr: options.split(','),
admin: admin,
adminKey: adminKey,
membersArr: members,
roomName: roomName,
isOpen: isOpen,
finalChoice: "A choice will be made when the room is closed",
timeStamp: timeStamp
});
return Rooms.find({}, {sort: {timeStamp: -1}});
});
This (in theory) should return a cursor to a document with all the information just passed in.
This is my subscribe:
var getRoom = Meteor.subscribe('addRoom', options, admin, adminKey, members, roomName, isOpen, finalChoice, timeStamp));
console.log(getRoom.adminKey.toString());
I know all those variables that are passed in are defined correctly, however that console.log(...)
gives me an undefined
error.
However, Rooms.find().fetch()
in the chrome's console does show the document correctly.
How can I get the admin key of the document correctly?
EDIT:
I should also note that I have Rooms = new Meteor.Collection('rooms');
at the top of both my sever-side and client-side javascript files.