Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Meteor } from 'meteor/meteor';
- import { Products} from '../imports/collections/products';
- import _ from 'lodash';
- import {image,commerce} from 'faker';
- Meteor.startup(() => {
- // code to run on server at startup
- const numberRecords=Products.find({}).count();
- console.log(numberRecords);
- if(!numberRecords){
- _.times(72,()=>{
- const productName=commerce.productName();
- const price=commerce.price();
- const productImage=image.food();
- const section=_.random(1,3);
- const category=_.random(1,4);
- Products.insert({productName,price,section,category,productImage:image.food()});
- });
- }
- Meteor.publish('products',function(PER_PAGE){
- return (Products.find({},{limit:PER_PAGE}));
- });
- });
Add Comment
Please, Sign In to add comment