Skip to content

vertingo/authentification-node.js-mongo-db

Repository files navigation

Image

🌐 Apporter votre soutien au projet ❤️ pour de futures évolutions!

GitHub stars GitHub forks GitHub watchers GitHub followers Twitter Follow Facebook YouTube Subscribe

🌐 Projet Authentification with Express MongoDB

App Progress Status Download

Download zip

📝 Author

Download MongoDB: https://www.mongodb.com/fr

Install MangoDB! Installation command:

C:\DevelopeWithVertin\MEAN\env\mongodb\bin\mongod.exe --dbpath C:\DevelopeWithVertin\MEAN\env\data

Launch MongoDb: C:\DevelopeWithVertin\MEAN\env\mongodb\bin\mongo.exe

In the command prompt of Visual Studio Code type: npm install mongoose

Add this to your models user.js for exemple var mongoose = require('mongoose');

Establish a connection to your mongo database: mongoose.connect('mongodb://localhost/testForAuth', function(err) { if (err) { throw err; } });

Create a table in your user.js remember that you don't need to type sql query with MongoDB var commentaireArticleSchema = new mongoose.Schema({ pseudo : { type : String, match: /^[a-zA-Z0-9-_]+$/ }, contenu : String, date : { type : Date, default : Date.now } });

Insert data in your database: // On le sauvegarde dans MongoDB ! monCommentaire.save(function (err) { if (err) { throw err; } console.log('Commentaire ajouté avec succès !'); // On se déconnecte de MongoDB maintenant mongoose.connection.close(); });

Open a commande prompt and launch the binary file an type the following command to verify that your data has been added properly! use blog switched to db blog show collections commentaires system.indexes db.commentaires.find() { « contenu » : « Salut, super article sur Mongoose ! », « pseudo » : « Atinux », « _id » : ObjectId(« 4e995dab2ea479d40f000001?), « date » : ISODate(« 2011-10-15T10:17:15.829Z ») }

🌐 Authentication Example with Node.JS and MongoDB App Progress Status


A simple example to show how authentication is implemented with Node.JS and MongoDB.

pic

Check out my post on medium.com

You can find a more detailed tutorial at treehouse:

A little boost follow us on YouTube and Facebook!
[You Tube]: https://www.youtube.com/channel/UC2g_-ipVjit6ZlACPWG4JvA?sub_confirmation=1
[Facebook]: https://www.facebook.com/vertingo/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published