Trying to retrieve a document by _id directly in template helper not working in meteor -



Trying to retrieve a document by _id directly in template helper not working in meteor -

i trying retrieve document straight in meteor via _id of document.

here helper:

template.lesson.helpers({ lesson: function() { //url format: http://localhost:3000/lesson/crofdsknbriy7qchl var url = window.location.href; var result= url.split('/'); var id = result[result.length-1]; console.log('url: '+url); console.log('id: '+id); var lessonsdata = lessons.findone({_id: id}); homecoming lessonsdata; } });

this correctly grabs id url.

i assume problem id beingness in string format.

how can pass value in format meteor/mongo looking id in? here error message receive.

exception in template helper: referenceerror: lessondata not defined

thanks much help!

updated question reference current error changes suggested.

also can not utilize iron router project since using parts of polymer don't work it.

to generate this.

//url format: http://localhost:3000/lesson/crofdsknbriy7qchl

you should have (for example).

//router.js router.route('/lesson/:_id', { name: 'lesson', data: function() { session.set('lessonid',this.params._id) //take id here. homecoming lessons.findone({_id: this.params._id); } });

and on helper.

template.lesson.helpers({ lesson: function() { //url format: http://localhost:3000/lesson/crofdsknbriy7qchl var id = session.get('lessonid') var lessonsdata = lessons.findone({_id: id}); //like around says don't need fetch(), since returning 1 object. homecoming lessonsdata; } });

editing question, seems have typo error, error says.

change homecoming on helper statement return lessonsdata

meteor

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -