Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get an instance of mongoose and mongoose.Schema
- var mongoose = require('mongoose');
- var Schema = mongoose.Schema;
- // set up a mongoose model and pass it using module.exports
- module.exports = mongoose.model('Accounts', new Schema({
- username: String,
- password: String
- }));
- app.get('/setup', function(req, res) {
- // create a sample user
- var nick = new User({
- username: 'user',
- password: 'password'
- });
- // save the sample user
- nick.save(function(err) {
- if (err) throw err;
- console.log('User saved successfully');
- res.json({ success: true });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement