Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 2.01 KB

README.md

File metadata and controls

70 lines (51 loc) · 2.01 KB

collection-faker

fake meteor collections, with support for grapher links

Installation

  1. Clone my forked version of grapher branch patch-1 (see this PR for more info)

    git clone [email protected]:macsj200/grapher.git

  2. Symlink the package into your app (or use METEOR_PACKAGE_DIRS environment variable)

  3. meteor add maxjohansen:collection-faker

Configuration

  1. Spin up your app, and pass it a settings file with SeedDatabase set to true

  2. Specify collections to seed with seedCollection(options)

API Documentation

seedCollection(options)

Options configuration

{
    collection,
    numItemsPerCollection = 20,
    numArrayElements = 5,
    preseed = [],
    mutators = [],
}
  • collection collection to seed
  • numItemsPerCollection how many items to seed, including preseeded items
  • numArrayElements how many elements to populate array keys with
  • preseed Definitions of objects to seed the collection with first. Only keys that are not specified will be generated. I.E. if you specify a name attribute, item.name === name, and all other fields will be generated on item.
  • mutators list of actions to perform after document insertion is complete. Specify mutateSelector mongo selection query object, and mutate(item) to specify logic.

Sample usage

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