Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.01 KB

README.md

File metadata and controls

61 lines (45 loc) · 1.01 KB

Meteor Populate

Populate your database filling with fake datas using simpleSchema and Collection2 on Meteor

Installation

> meteor add gbit:populate

How to use

In Meteor Collections

Meteor.startup(function(){
	// Say how much fakes you need
	// Default is 3
	Populate.amount = 5;
	// Insert five fakes
	Products.populate();
	// You can pass argument with number of fakes
	Users.populate(3);
	// Return 3 fake users and insert in your db if is empty
});

You Can Personalize de fake in SimpleSchema Definitions (optional)

Meteor populate use faker.js to fill fields

var Users =	new SimpleSchema({
	name: {
		type: String,
		fill: faker.METHOD.NAME
	},
	email: {
		type: String,
		fill: function(){
			return Users.findOne().email; 
		}
	}
});

You Can Generate a fake from SimpleSchema without save in database

Template.demo.helpers({
	user: function(){
		return Populate.fakeFromSchema( UserSchema );
	}
});