This file contains hidden or 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
| module['exports'] = function highFive(hook) { | |
| // hook.io has a range of node modules available - see | |
| // https://hook.io/modules. | |
| // We use request (https://www.npmjs.com/package/request) for an easy way to | |
| // make the HTTP request. | |
| var request = require('request'); | |
| // The parameters passed in via the slash command POST request. | |
| var params = hook.params; |
This file contains hidden or 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
| module['exports'] = function registerIO(hook) { | |
| // hook.io has a range of node modules available - see | |
| // https://hook.io/modules. | |
| // We use request (https://www.npmjs.com/package/request) for an easy way to | |
| // make the HTTP request. | |
| var request = require('request'); | |
| var mongoose = require('mongoose'); | |
| mongoose.connect('mongodb://moelia:[email protected]:35663/employees_activity'); | |
This file contains hidden or 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 mongoose = require('mongoose'); | |
| var schema = new mongoose.Schema({ | |
| name: { | |
| type: String, | |
| required: true, | |
| index: {unique: true} | |
| }, | |
| banned: { |
This file contains hidden or 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 User = require('route/to/models/User.js'); | |
| // Find a user by his ID | |
| User.findById(<here_the_id>, function (error, user) { | |
| if (error) throw error; | |
| console.log(user); | |
| }); |
This file contains hidden or 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 User = require('route/to/models/User.js'); | |
| // Find a user by his ID | |
| User.findById(<id>, function(error, user) { | |
| if (error) throw error; | |
| user.banned = true; | |
| // Save the changes | |
| user.save(function(error) { |
This file contains hidden or 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 User = require('route/to/models/User.js'); | |
| // Find a user by his ID | |
| User.findById(<id>, function(error, user) { | |
| User.getFriends(user.id, function(error2, friends) { | |
| User.getJobs(user.id, function(error3, jobs) { | |
| ... |
This file contains hidden or 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 mongoose = require('mongoose'); | |
| var schema = new mongoose.Schema({ | |
| name: { | |
| type: String, | |
| required: true, | |
| index: {unique: true} | |
| }, | |
| banned: { |
This file contains hidden or 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 User = require('route/to/models/User.js'); | |
| User.findUserById(<id>).then(function(user) { | |
| user.banned = true; | |
| return User.saveUser(user); | |
| }).then(function() { | |
| return User.removeUserByName('manuel'); |
This file contains hidden or 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
| Promise.all([User.findAllUsers(), User.findUserById(<id>)]).then(function(results) { | |
| // results[0] contains the result of the first promise | |
| // results[1] contains the result of the second promise | |
| }); |
This file contains hidden or 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
| Promise.all([User.findAllUsers(), User.findUserById(<id>)]).then(function(results) { | |
| // results[0] contains the result of the first promise | |
| // results[1] contains the result of the second promise | |
| }); |
OlderNewer