fixtures.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. });
  27. Comments.insert({
  28. postId: telescopeId,
  29. userId: tom._id,
  30. author: tom.profile.name,
  31. submitted: new Date(now - 5 * 3600 * 1000),
  32. body: 'Interesting project Sacha, can I get involved?'
  33. });
  34. Comments.insert({
  35. postId: telescopeId,
  36. userId: sacha._id,
  37. author: sacha.profile.name,
  38. submitted: new Date(now - 3 * 3600 * 1000),
  39. body: 'You sure can Tom!'
  40. });
  41. Posts.insert({
  42. title: "Meteor",
  43. userId: tom._id,
  44. author: tom.profile.name,
  45. url: "http://meteor.com",
  46. submitted: new Date(now - 10 * 3600 * 1000)
  47. });
  48. Posts.insert({
  49. title: "The Meteor book",
  50. userId: tom._id,
  51. author: tom.profile.name,
  52. url: "http://themeteorbook.com",
  53. submitted: new Date(now - 12 * 3600 * 1000)
  54. });
  55. }
  56. else {
  57. Meteor._debug('Posts collection is not empty');
  58. }