nathanathan / meteor-autoform-fixtures

Get fixtures data from SimpleSchema with AutoForm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

comerc:autoform-fixtures

Get fixtures data from SimpleSchema with AutoForm.

Usage

It is creating random/fake data automatically based on the collection schema.

ss = Collections.MyCollection.simpleSchema()
data = AutoForm.Fixtures.getData(ss)
Collections.MyCollection.insert(data)

You may use autoform.omit for exclude fields:

MyCollection.attachSchema new SimpleSchema
  userId:
    type: String
    autoform:
      omit: true
    autoValue: ->
      Meteor.userId()

You may use anti:fake with getFakeTextCallback

getFakeText = (fieldName, maxLength) ->
  if fieldName is "my.name"
    Fake.word()
  else if maxLength
    Fake.sentence(Math.round(maxLength / 10))
  else
    Fake.paragraph()
  
data = AutoForm.Fixtures.getData(ss, getFakeText)

You may use intermediate operations with namespace in mongo-style

data = AutoForm.Fixtures.getPreData(ss)
data["my"] = {} 
data["my.name"] = "foo"
data = AutoForm.Fixtures.normalizeData(data)
# {my: name: "foo"}

About

Get fixtures data from SimpleSchema with AutoForm

License:MIT License


Languages

Language:CoffeeScript 91.2%Language:JavaScript 8.8%