"use strict";

const { Router } = require('express')
const router = Router()
const Item = require('../models/Item')

router.get('/api/items', (req, res, err) =>
  Item
    .find()
    .then(item => res.json( item ))
    .catch(err)
)

////////just returning a single id by its id//////////
router.get('/api/items/:_id', (req, res, err) =>
  Item
    .findById(req.params._id)
    .then((item) => res.json( item ))
    .catch(err)
)


 router.post('/api/items', (req, res, err) => {
   Item
   .create(req.body)
   .then((items) => res.json(items))
   .catch(err);
  });

// router.put('/api/items/:_id', (req, res, err) => {
// 	Item
// 	.update({ _id:req.params.id }, {$set: { name: "lalallalalala" }})
// 	.then(items => res.json(items))
// 	.catch(err)
// })


module.exports = router

@@ -564,19 +564,16 @@
 %0A  %7D);%0A%0A
-// 
 router.p
@@ -619,23 +619,27 @@
 %3E %7B%0A
-// 
 %09Item%0A
-// %09.u
+%09.findOneAndU
 pdat
@@ -657,16 +657,17 @@
 .params.
+_
 id %7D, %7B$
@@ -684,42 +684,34 @@
 e: %22
-lalallalalala
+1234566
 %22 %7D%7D)%0A
-// 
 %09.then(
+(
 item
-s
+)
  =%3E 
@@ -727,15 +727,11 @@
 item
-s
 ))%0A
-// 
 %09.ca
@@ -743,11 +743,8 @@
 rr)%0A
-// 
 %7D)%0A%0A

PUT API route is now working in postman