Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mongoose = require('mongoose');
- const Schema = mongoose.Schema;
- //Create the Item Schema
- const ItemSchema = new Schema({
- name: {
- type: String,
- required: true,
- },
- date: {
- type: Date,
- default: Date.now
- }
- });
- module.exports = Item = mongoose.model('item', ItemSchema);
- router.post('/', (req, res) => {
- const newItem = new Item({
- name: req.body.name
- });
- newItem.save()
- . then(item => res.json(item));
- });
- module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement