iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

A simple example on how to view a record in mongodb #1518

Closed openqubit closed 8 years ago

openqubit commented 8 years ago

I have a books crud app that i have made and i need to view an individual item. My url looks like this

http://localhost:3000/crud/view/cwfet5RZxkZqog2s5

This is my code inside the CrudController

  view: function() {
   this.render('Viewed', {to: 'viewer'});
 },

This is my route

Router.route('/crud/view/:_id', {
  name: 'view',
  controller: 'CrudController',
  action: 'view',
  where: 'client'
});

and this is my helper
Template.Viewed.helpers({
  'crud/view/:id': function(){
 return Crud.findOne({_id: this.params._id});
    }
});

My code as is gives me a blank when i try to access the db value in the template like{{name}}

Can someone guide me on how to set up my code when i have the url am having.