Advertisement
Guest User

Untitled

a guest
Jun 4th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // get an instance of mongoose and mongoose.Schema
  2. var mongoose = require('mongoose');
  3. var Schema = mongoose.Schema;
  4.  
  5. // set up a mongoose model and pass it using module.exports
  6. module.exports = mongoose.model('Accounts', new Schema({
  7. username: String,
  8. password: String
  9. }));
  10.  
  11. app.get('/setup', function(req, res) {
  12.  
  13. // create a sample user
  14. var nick = new User({
  15. username: 'user',
  16. password: 'password'
  17. });
  18.  
  19. // save the sample user
  20. nick.save(function(err) {
  21. if (err) throw err;
  22.  
  23. console.log('User saved successfully');
  24. res.json({ success: true });
  25. });
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement