I have a collection called ChatRooms that has an array of chatIds, which are just the user Ids of who is in the chatroom. There are only two ids in the array at a time. I want to find the first element in this array and set it to the variable "messager" so that i can see if it belongs to the person currently logged in. if not, the message that was just sent will be added to a different collection called notifications, so that the other user can be notified of receiving a message. I keep getting syntax errors on the query, and I don't know why. Here is my block of code:
createMessageNotification = function(message) {
var messager = ChatRooms.find( {}, { chatIds: { $slice: 0,1 } } );
//console.log(messager);
if(messager !== Meteor.userId()){
Notifications.insert({
message: message.value
});
}
}