This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Once you get to next(); it moves on to the next function and lets go of whatever information was captured there. | |
// for instance mariaItem finds the item with that particular _id and when it hits the next(); that information is gone... | |
// UNLESS | |
// You add a req.contents = {}; with that you are adding to the request hash a contents key and {} value. | |
// It always will pass the req, res, option for next. | |
// Next you add a result key with a result value. (The result value holds the the work of findOne). | |
// So that information is now stored in the res hash and when the computer goes to next function it takes that info with it. | |
var mariaItem = function (req, res, next) { | |
Item.findOne({ _id: "5099803df3f4948bd2f98391"}, function (err, result){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Pull out the item with that id add it to the req.contents hash then go to next function... | |
var mariaItem = function (req, res, next) { | |
Item.findOne({ _id: "5099803df3f4948bd2f98391"}, function (err, result){ | |
//res.json(result); | |
//var firstOne = res.json(result); | |
//{ field: { $in: [<value1>, <value2>, ... <valueN> ] } } | |
//Group.find({_id: {$in: req.contents.item.groups}}, function (err, groups) { | |
req.contents = {}; | |
req.contents.result = result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SO here I have gone from having to call three different functions to only calling one (mariaView) | |
// I took //mariaItem, | |
//mariaTwo, | |
//mariaS, | |
//mariaG | |
// and wrapped them in one function mariaView that then uses async waterfall. | |
// This will NOT work with async parallel because parallel does all the functions at the same time, and the | |
// second, third and fourth functions need the info from the first function to succeed. | |
var mariaView = function (req, res, next){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here mariaItem is called first and then moves onto mariaView. | |
// mariaView has two callbacks happening asynchronously but they need the info from mariaItem first. | |
var mariaItem = function (req, res, next) { | |
Item.findOne({ _id: "5099803df3f4948bd2f98391"}, function (err, result){ | |
req.contents = {}; | |
req.contents.result = result; | |
next(); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Terminal #1 run: | |
mongod --setParameter textSearchEnabled=true | |
Terminal #2 run: | |
npm start | |
Terminal #3 run: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//See more here: http://stackoverflow.com/questions/572897/how-does-javascript-prototype-work | |
//Define a functional object to hold persons in JavaScript | |
var Person = function(name) { | |
this.name = name; | |
}; | |
//Add dynamically to the already defined object a new getter | |
Person.prototype.getName = function() { | |
return this.name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mariaItem = function (req, res, next) { | |
Item.findOne({ _id: "5099803df3f4948bd2f98391"}, function (err, result){ | |
req.contents = {}; | |
req.contents.result = result; | |
next(); | |
}); | |
}; | |
var mariaView = function (req, res, next){ | |
async.waterfall([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--In the Dashboard.njs--> | |
<div class="dashboard-item-offer box {{"invisible" if offer.isHidden}} {{"offer-to-rate" if offer.state == "rescinded" and not offer.ratedBySeller }}"> | |
<div class="col col-1of4-md col-1of1-xs"> | |
{% include "partials/userthumb.njs" %} | |
{% include "partials/modals/message.njs" %} *****This tells the button where to go | |
<div class="offerer"> | |
<p class="offerer-name">{{offer.offerer.name}}</p> | |
<p class="offerer-location">{{offer.offerer.location.city}}, {{offer.offerer.location.state}}</p> | |
<a><button type="submit" class="bttn6 seller-message" data-toggle="modal" data-target="#modalSellerMessage"> Message</button></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends '/layouts/layout.njs' %} | |
{% block contenttype%}item-form{%endblock%} | |
{% block content %} | |
{% if item.summary and item.title and (item.ship or item.exchange) and item.category and (item.images|length > 0) and (item.groups|length > 0) and (item.state != "open") %} | |
{% set isPublishable = 1 %} | |
{% else %} | |
{% set isPublishable = 0 %} | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends '/layouts/layout.njs' %} | |
{% block content %} | |
<div class="box "> | |
<aside class="container"> | |
<div class="col col-1of1-xs"> | |
<h1>Create a group</h1> | |
<br> | |
</div> | |
</aside> |
OlderNewer