Hey.

Consider adding this to your module:

module.exports.view = function...
module.exports.Post={};

Now, you can modify the second Post variable with...

var View = require(...);
View.Post={dat:"dude"};

Should help.

Otherwise, you may use the globals object - its global everywhere, and the same 
everywhere. So if yo use:

global.my_Post={dat:"dude"};

You can do the same in your module with:

console.log("Dat", global.my_Post.dat);

Hope it helps in a way. ^^

Kind regards, Ingwie
Am Di. Feb. 25 2014 16:44:55 schrieb Ziobudda:

> Hi all, In my nodes app (nodejs+express+jade) I want use module to manage a 
> route. 
> 
> In my code I have these lines (only the important ones): 
> 
> var express = require('express');
> var routes = require('./routes');
> var Stats = require("./routes/view_stat.js");
> var mongoose = require('mongoose');
> var db = mongoose.connect('mongodb://localhost/articoli');
> 
> var Schema = mongoose.Schema;
> var Articoli = new Schema({
>   .....
> });
> 
> mongoose.model('Articoli', Articoli);
> var Post = mongoose.model('Articoli');
> 
> app.get('/view/:nid', Stats.view);
> 
> Now, in my Stats.view function (inside view_stats.js file) I need to "pass": 
> req, res and Post.
> 
> A code like this one (tell me if there is an error):
> 
> module.exports = function view(req,res,Post) {
> 
>   res.render('stats', { 'nid' : req.params.nid });
> };
> 
> 
> But how can I "pass" these variables to my module ? 
> 
> Thanks and sorry for my bad english.
> 
> M.
> -- 
> Michel 'ZioBudda' Morelli                       [email protected]
> Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax)
> Telefono: 0200619074
> Mobile: +39-3939890025 --  Fax: +39-0291390660
> 
> http://www.ziobudda.net                         Skype: zio_budda
> http://www.ziobuddalabs.it                     Twitter: ziobudda
> 
> --



-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to