fixtures.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * @file
  3. *
  4. *
  5. * User: marand
  6. * Date: 30/08/15
  7. * Time: 11:33
  8. */
  9. if (Posts.find().count() === 0) {
  10. var now = new Date().getTime();
  11. // Create two users.
  12. var tomId = Meteor.users.insert({
  13. profile: {name: 'Tom Coleman'}
  14. });
  15. var tom = Meteor.users.findOne(tomId);
  16. var sachaId = Meteor.users.insert({
  17. profile: {name: 'Sacha Greif'}
  18. });
  19. var sacha = Meteor.users.findOne(sachaId);
  20. var telescopeId = Posts.insert({
  21. title: "Introducing Telescope",
  22. userId: sacha._id,
  23. author: sacha.profile.name,
  24. url: "http://sachagreif.com/introducing-telescope",
  25. submitted: new Date(now - 7 * 3600 * 1000),
  26. commentsCount: 2
  27. });
  28. Comments.insert({
  29. postId: telescopeId,
  30. userId: tom._id,
  31. author: tom.profile.name,
  32. submitted: new Date(now - 5 * 3600 * 1000),
  33. body: 'Interesting project Sacha, can I get involved?'
  34. });
  35. Comments.insert({
  36. postId: telescopeId,
  37. userId: sacha._id,
  38. author: sacha.profile.name,
  39. submitted: new Date(now - 3 * 3600 * 1000),
  40. body: 'You sure can Tom!'
  41. });
  42. Posts.insert({
  43. title: "Meteor",
  44. userId: tom._id,
  45. author: tom.profile.name,
  46. url: "http://meteor.com",
  47. submitted: new Date(now - 10 * 3600 * 1000),
  48. commentsCount: 0
  49. });
  50. Posts.insert({
  51. title: "The Meteor book",
  52. userId: tom._id,
  53. author: tom.profile.name,
  54. url: "http://themeteorbook.com",
  55. submitted: new Date(now - 12 * 3600 * 1000),
  56. commentsCount: 0
  57. });
  58. }
  59. else {
  60. Meteor._debug('Posts collection is not empty');
  61. }