Guest User

Untitled

a guest
May 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. const mongoose = require('mongoose');
  2. const Schema = mongoose.Schema;
  3.  
  4. mongoose.Promise = global.Promise;
  5. mongoose.connect('mongodb://localhost/test-clone', {useMongoClient: true});
  6.  
  7. const Status = new Schema({
  8. author: String,
  9. content: String,
  10. date: Date,
  11. like: Number,
  12. });
  13.  
  14. const StatusModel = mongoose.model('Status', Status);
  15.  
  16. const statusData = [
  17. {
  18. author: "me",
  19. content: "My first status",
  20. date: new Date(),
  21. like: 7
  22. },
  23. {
  24. author: "me",
  25. content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
  26. date: new Date(),
  27. like: 8
  28. },
  29. {
  30. author: "me",
  31. content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
  32. date: new Date(),
  33. like: 3
  34. },
  35. {
  36. author: "me",
  37. content: "Yet another status",
  38. date: new Date(),
  39. like: 4
  40. },
  41. ]
  42.  
  43. statusData.forEach((status) => {
  44. const newStatus = new StatusModel((status));
  45. newStatus.save();
  46. })
Add Comment
Please, Sign In to add comment