Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. const mongoose = require('mongoose');
  2. const Schema = mongoose.Schema;
  3.  
  4. //Create the Item Schema
  5. const ItemSchema = new Schema({
  6. name: {
  7. type: String,
  8. required: true,
  9. },
  10. date: {
  11. type: Date,
  12. default: Date.now
  13. }
  14. });
  15.  
  16. module.exports = Item = mongoose.model('item', ItemSchema);
  17.  
  18.  
  19. router.post('/', (req, res) => {
  20. const newItem = new Item({
  21. name: req.body.name
  22. });
  23. newItem.save()
  24. . then(item => res.json(item));
  25. });
  26.  
  27.  
  28. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement