Node.js Modules | Node.js Module.exports | Node.js Tutorial | Edureka

preview_player
Показать описание

Networking (HTTP, TCP, UDP, DNS, or TLS/SSL), Binary data (buffers), Cryptography functions, Data streams, and other core functions.Node's modules have a simple and elegant API, reducing the complexity of writing server applications.

Video gives a brief insight of following topics:

1.Overview of Javascript
5.Installing Node.JS

Related Post :

Edureka is a New Age e-learning platform that provides Instructor-Led Live, Online classes for learners who would
prefer a hassle free and self paced learning environment, accessible from any part of the world.

Рекомендации по теме
Комментарии
Автор

Thank you for making this video. It was very helpful. However, can you kindly help me understand what the piece of code below?

var mongoose = require('mongoose');
var bcrypt = require('bcrypt');



var db = mongoose.connection;

// User Schema
var UserSchema = mongoose.Schema({
//Schema detail
});

var User = module.exports = mongoose.model('User', UserSchema);

module.exports.createUser = function(newUser, callback) {
bcrypt.hash(newUser.password, 10, function(err, hash){
if(err) throw err;
// Set hashed pw
newUser.password = hash;
// Create User
newUser.save(callback)
});
}

I don't quite get what this line - "var User = module.exports = mongoose.model('User', UserSchema);", is try to do. Is it User needed somewhere else? Why cannot it be just "var User = mongoose.model('User', UserSchema);"


Thank you so much if you can help.

jasdnbsad