Skip to content

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

Notifications You must be signed in to change notification settings

zalew/meteor-populate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 );
	}
});

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published