mongodb - Can't get any db data out of Meteor -


i completed meteor 'simple todo' tutorial , thought i'd gotten basic gist of how works. i'm starting own project , hitting problems immediately.

whatever try cannot data out of meteor , template, or console.log. it's undefined. i've double-checked collections via meteor mongo in terminal , data i'm passing in correct. i've tried hardcoding document id.

i'm hoping can point @ must wrong code.

this current iteration doesn't work, seem have tried every variation can find on net:

js:

pros = new mongo.collection("pros");  if (meteor.isclient) {   meteor.subscribe("pros");   router.configure({     layouttemplate: 'main'   });   router.route('/brief/:_id', function () {     this.render('brief', {       data: function(){             var proid = this.params._id;             return pros.findone({ _id: proid });         }     });   }); } if(meteor.isserver){   meteor.publish("pros", function () {     return pros.find();   }); } 

html:

<template name="main">     <h1>title here</h1>     {{> yield}} </template>  <template name="brief">   <h2>{{ name }}</h2> </template> 

(i've tried above in foreach on pros)

db data (via find command in terminal)

db.pros.find({}); { "_id" : objectid("55915761145c29018ac97edb"), "name" : "jimbob" } 

i've tried following hasn't yielded different results (it stays on loading state):

pros = new mongo.collection("pros");  if (meteor.isclient) {   router.configure({     layouttemplate: 'main'   });   router.route('/brief/:_id', {     loadingtemplate: 'loading',     waiton: function () {       return meteor.subscribe('pros', this.params._id);     },     action: function () {       this.render('brief');     }   }); } if(meteor.isserver){   meteor.publish('pros', function(proid) {     return pros.findone(proid);   }); } 

any ideas?

you're using objectids in meteor isn't default (meteor generates 17 character strings instead of mongo objectids when inserting documents)

try like:

data: function () {     pros.findone({ _id: new mongo.objectid(this.params._id)}); } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -