How is it possible to retrieve a particular element in an array as a string? I have populated a field called 'list' which consist of document id's from Posts collection.
The postId's are inserted in the following manner within my method:
var postId = //code for retrieving post id
Meteor.users.update( this.userId, { $addToSet: { 'profile.list': postId}});
Now, I retrieve the first postId value to find that Post document.
var postId = Meteor.user().profile.list;
Posts.update( {_id: postId}, { $addToSet: {'message': sometext}});
The update does not work as it appears in my console log I am retrieving an object [ 'SvNJAZWNFW8fpobJv' ] - not a string. If I were to manually insert the postId value enclosed with speech marks, it would work.
How can I target a specific position of the 'list' field and use the value to perform the update?