Data generators are functions that return data. That data can be random or follow
specific patterns. mongoose-fakery comes with a number of pre-defined data generators
which will probably suit most of your needs i.e:

random strings (hex, alpha, alphanum)

random numbers

random booleans (true/false)

lorem generator

name, surname and gender

picking random items from lists

Pre-defined data generators are exposed under the g attribute of the fakery
object. Take a look in data_providers.js to see all the available generators
and their APIs.

Some examples:

// using the user model defined above

fakery.fake('user', mongoose.model('User'),{

name: fakery.g.name(),

surname: fakery.g.surname()

});

Generators can also be used in arrays and nested attributes:

fakery.fake('post', mongoose.model('Post'),{

name: fakery.g.name(),

// this will create tags 'projects', <random string>, 'tech'

tags:['projects', fakery.g.str(5),'tech']

});

Data generators can also be used when you just want to generate a bunch of random
data for whatever purpose. They are not specific to test factories: