meteormeteor-publications

How to publish document ID?


I am trying to access document _id in the client

Here is how I am publishing it:

Meteor.publish('events', function () {
        return Requests.find({}, {fields: {"_id": 1, 'start': 1, 'title': 1, 'reasons': 1}});
    });

and in the client when I try to console.log() the id, I get "_fc4" printed to the console

Here is my code (in the client):

eventClick: function(event, jsEvent, view) {
            console.log(event._id);

        }

event is the documents returned. I get the correct value when printing event.title, event.start, or event.reasons to the console. But I get _fc4 when trying event._id.

My question now is, how to publish the _id correctly?

NOTE: Tried to change "_id" with _id and received the same results in the console


Solution

  • I believe your printing the event id in the calendar, not your document in the database.

    make sure you set the event id to your document id before adding it to the calendar