Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. require("../src/db/mongoose");
  2. const User = require("../src/model/user");
  3. const Task = require("../src/model/task");
  4. User.findByIdAndUpdate("5c8ce6e8beb985736310618f", { age: 1 })
  5. .then(user => {
  6. console.log(user);
  7. return User.countDocuments({ age: 1 });
  8. })
  9. .then(result => {
  10. console.log(result);
  11. })
  12. .catch(e => {
  13. console.log(e);
  14. });
  15.  
  16.  
  17. // same thing apply to task
  18.  
  19. Task.findByIdAndDelete("5c8d373015cd9f96a0a7843f")
  20. .then(task => {
  21. console.log(task);
  22. return Task.countDocuments({ completed: false });
  23. })
  24. .then(result => {
  25. console.log(result);
  26. })
  27. .catch(e => {
  28. console.log(e);
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement