Exporting Objects with the Exports Object

This is the way I create modules: myModule.js var MyObject = function() { // This is private because it is not being return var _privateFunction = function(param1, param2) { … return; } var function1 = function(param1, callback) { … callback(err, results); } var function2 = function(param1, param2, callback) { … callback(err, results); } return { … Read more

Node 7.1.0 new Promise() resolver undefined is not a function

The API for promises requires you to pass a function to the promise constructor. Quoting MDN: new Promise( /* executor */ function(resolve, reject) { … } ); executor – A function that is passed with the arguments resolve and reject. The executor function is executed immediately by the Promise implementation, passing resolve and reject functions … Read more

nodejs fs.exists()

Your require statement may be incorrect, make sure you have the following var fs = require(“fs”); fs.exists(“/path/to/file”,function(exists){ // handle result }); Read the documentation here http://nodejs.org/api/fs.html#fs_fs_exists_path_callback

Mongoose sort the aggregated result

The results returned from the aggregation pipeline are just plain objects. So you do the sorting as a pipeline stage, not as a separate operation: Recommend.aggregate( [ // Grouping pipeline { “$group”: { “_id”: ‘$roomId’, “recommendCount”: { “$sum”: 1 } }}, // Sorting pipeline { “$sort”: { “recommendCount”: -1 } }, // Optionally limit results … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)