startup.js 419 B

123456789101112131415
  1. if (Meteor.isServer) {
  2. Meteor.startup(function () {
  3. if (Images.find().count() === 0) {
  4. for (let i = 1; i < 23; i++) {
  5. Images.insert({
  6. "img_src": "img_" + i + ".jpg",
  7. "img_alt": "image number " + i
  8. });
  9. } // end of for insert images
  10. // count the images!
  11. console.log("startup.js says: " + Images.find().count());
  12. } // end of if have no images.
  13. });
  14. }