Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. const Shop = require("../../models/shopModel")
  2.  
  3. class UpdateShop {
  4. constructor(id,req) {
  5. this.name = req.body.name,
  6. this.description = req.body.description,
  7. this.owner = req.body.owner,
  8. this.id = id
  9. }
  10.  
  11. async update() {
  12. try {
  13. let data = new Shop({
  14. name: this.name,
  15. description: this.description,
  16. owner: this.owner,
  17. _id: this.id
  18. })
  19. let query = await Shop.findOneAndUpdate({
  20. _id: this.id
  21. },data).exec()
  22.  
  23. return query
  24. } catch(err) {
  25. throw err
  26. }
  27. }
  28. }
  29.  
  30. module.exports = UpdateShop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement