Since your documents use the MongoDB identifier format rather than the standard Meteor ID format (just a randomly generated string), you will need to use the MongoDB ObjectId.toString() function described. But, unfortunately, this simply causes your ObjectID to print as a string of type ObjectID("54f27a1adfe0c11c824e04e9") .
I would recommend creating a document identifier template helper that will clear your document identifiers before including them in the template. Since this problem is most likely related to all of your documents in all your collections, I would also suggest creating a global template helper. This can be done like this:
Template.registerHelper('cleanDocumentID', function(objectID) { var objectIdString = objectID.toString(); var cleanedString = objectIDString.slice(objectIDString.indexOf('"') + 1, -2); return cleanedString; });
This template helper only cuts the actual string of the object identifier from the string provided by the ObjectId.toString() function. You can use this template helper in your templates like this:
{{cleanDocumentID _id}}
I know this is a lot more messy than just using the document identifier in the template, for example {{_id}} , but this is necessary because your documents have a document identifier of type ObjectID of type MongoDB, and not a simple random generated string used Meteor by default.
If you want to learn more about how to configure MongoDB collections to use randomly generated strings for document identifiers and avoid this mess, check out this .
source share