fake meteor collections, with support for grapher links
-
Clone my forked version of grapher branch
patch-1(see this PR for more info)git clone git@github.com:macsj200/grapher.git -
Symlink the package into your app (or use
METEOR_PACKAGE_DIRSenvironment variable) -
meteor add maxjohansen:collection-faker
-
Spin up your app, and pass it a settings file with
SeedDatabaseset totrue -
Specify collections to seed with
seedCollection(options)
Options configuration
{
collection,
numItemsPerCollection = 20,
numArrayElements = 5,
preseed = [],
mutators = [],
}collectioncollection to seednumItemsPerCollectionhow many items to seed, including preseeded itemsnumArrayElementshow many elements to populate array keys withpreseedDefinitions of objects to seed the collection with first. Only keys that are not specified will be generated. I.E. if you specify anameattribute,item.name === name, and all other fields will be generated onitem.mutatorslist of actions to perform after document insertion is complete. SpecifymutateSelectormongo selection query object, andmutate(item)to specify logic.
Add SeedDatabase to your settings.json file
{
"SeedDatabase" : true
}Optionally, you can elect to add an extra settings parameter, clearDbBeforeSeed, which will drop the database upon every app reload (recommended only for development of this package).
{
"SeedDatabase" : true,
"clearDbBeforeSeed": true
}In server code
import {seedCollection} from "meteor/maxjohansen:collection-faker";
seedCollection({
collection:Meteor.users,
numItemsPerCollection:15,
});