Advertisement
Guest User

Untitled

a guest
May 3rd, 2017
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RegisterUser: function (username, password) {
  2.             mongoose.connect(url);  //connect to your mongodb database.
  3.             var User = mongoose.model('Customers', {    //define what a user looks like in the database.
  4.                 username: { Type: String, unique: true, required: true },
  5.                 password: { type: String, required: true }
  6.             });
  7.  
  8.             var newCustomer = new User({ username: 'username', password: 'password' });  //make a new user
  9.             newCustomer.save(function (err) {
  10.                 if (err) {
  11.                     console.log(err);
  12.                 } else {
  13.                     console.log('added new Customer :' + JSON.stringify(newCustomer));
  14.                 }
  15.             });
  16.  
  17.         },
  18.  
  19.  
  20.  
  21. {
  22.   "name": "test",
  23.   "version": "0.0.0",
  24.   "description": "Test",
  25.   "main": "app.js",
  26.   "author": {
  27.     "name": "ilav"
  28.   },
  29.   "dependencies": {
  30.     "mongodb": "^2.2.26",
  31.     "mongoose": "^4.9.7"
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement