Note that there are some explanatory texts on larger screens.

plurals
  1. POCreated Document Comes up in Show Mongodb, Node.js, Express.js
    text
    copied!<p>I'm working on a Node.js app with Express.js and Mongodb and I'm having some trouble getting it to cooperate with me. The app is essentially a list of Recipes with it's ingredients. It works fine when I start the App. I can click to view a recipe and it shows the right one but the second I create a new one it seems to get "stuck" and the only recipe I'll see is the newly created one. But it shows the title to the right recipe on the top. Which is really confusing me.</p> <p>Here's a Screenshot of what's happening if that helps at all. This is what's happening when I create an Eggs Benedict Recipe and click on the already existing "Chili" recipe:</p> <p><img src="https://i.stack.imgur.com/MjQub.png" alt="Issue"></p> <p>Here's my Code: </p> <p>Recipe_show.jade</p> <pre><code>h1= title div.recipe div.name= recipe.name - each ingredient in recipe.ingredients div.ingredient div.amount= ingredient.amount div.measurement= ingredient.measurement div.type= ingredient.type </code></pre> <p>recipeprovider.js</p> <pre><code>//find an recipe by ID RecipeProvider.prototype.findById = function(id, callback) { this.getCollection(function(error, recipe_collection) { if( error ) callback(error) else { recipe_collection.findOne({_id: recipe_collection.db.bson_serializer.ObjectID.createFromHexString(id)}, function(error, result) { if( error ) callback(error) else callback(null, result) }); } }); </code></pre> <p>};</p> <p>app.js</p> <pre><code>// show individual recipes app.get('/recipe/:id', function(req, res) { recipeProvider.findById(req.params.id, function(error, recipe) { res.render('recipe_show.jade', { title: recipe.name, recipe: recipe }); }); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload