daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Aug 12th, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import express = require('express');
  2. let router = express.Router();
  3. let mongoose = require('mongoose');
  4.  
  5. let User = mongoose.model('User', {
  6.   email: String,
  7.   password: String,
  8.   date_created: Date,
  9.   date_deleted: {
  10.     type: Date,
  11.     default: null
  12.   }
  13. });
  14.  
  15. router.post('/users', function(req, res, next) {
  16.   let new_user = new User({
  17.     email: req.body.email,
  18.     password: req.body.password,
  19.     date_created: new Date()
  20.   });
  21.   new_user.save(function (err, user) {
  22.     if (err) {
  23.       console.log(err);
  24.     } else {
  25.       console.log(user);
  26.     }
  27.     res.send(user);
  28.   })
  29. });
  30.  
  31. export = router;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top