Come posso aggiungere un nuovo campo all'utente attualmente connesso nel documento usando "Meteor.user ()"?
NOTA: sto usando meteoris pacchetti per creare e gestire i miei utenti
risposte:
1 per risposta № 1Puoi usare
Meteor.users.update({ _id: Meteor.userId() },{ $set: { "propertyHere": valueOfPropertyHere } });
Nota: se si sta aggiornando l'utente dal client, è necessario assicurarsi di disporre delle autorizzazioni corrette, anche il Meteor.userId()
funzionerebbe.
Se lo stai facendo dal server, modifica il Meteor.userId()
a this.userId
.. testato su Meteor 1.6