Hi, I’m trying to make a list of similar records for allApp, when I try to publish the data so that they are only displayed for a specific user, I only get them to keep showing the same data to all registered users. I only wish that if that user keeps that data to them Show only for him.
I leave the code to see if anyone helps me with the cause of the problem.
/// client
AddPerson = new Mongo.Collection("addperson");
Template.AddPersonas.onCreated(function(){
this.autorun(() => {
this.subscribe('people');
});
});
Template.AddPersonas.events({
'submit #formPersona' (event, template) {
event.preventDefault();
const target = event.target;
var name = target.name.value;
var lastname= target.lastname.value;
var phone= target.phone.value;
var selectPerson= target.selectPerson.value;
// var hora= target.time.value;
// var Recordatorio= target.Recordatorio.value;
if (selectPerson==="Otro"){
selectPerson= target.otro.value;
} else{
selectPerson=selectPerson;
}
let objPerson= {
name: name,
lastname:lastname,
phone:phone,
selectPerson:selectPerson
}
Meteor.call('addTodo', objPerson);
},
});
/// server
Meteor.methods({
addTodo: function(objPerson){
AddPerson.insert( {
name: objPerson.name,
lastname: objPerson.lastname,
phone:objPerson.phone,
selectPerson:objPerson.selectPerson,
createdAt: new Date(),
userId: Meteor.userId(),
});
},
});
/// publish.js
Meteor.publish('people', function(){
return AddPerson.find({});
// return AddPerson.find({_id: this.userId});
});