fixtures.js 1.4 KB

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