@aida/injector-faked-model
v0.0.7
Published
Aida faked model injector
Downloads
16
Readme
Injector - Faked Model
Introduction
The Faked Model injector generates an array of fake data for each of the specified models.
Dependencies
The Faked Model injector has no dependencies.
Use Cases
The main use case for this injector is to generate a larger amount of fake data that can later be used to insert into development databases or for other similar uses.
Example
//This is what will be generated by fakedModel. Check the supported options for more details on the generated data.
const fakedModels = {
"User": [
{
"id": "27bd418b-05e0-4e40-9fb2-54a9ff7de038",
"address": {
"city": "Nara",
"street": "914 Al Spring Suite 191"
}
}
],
"Product": [
{
"name": "Shampoo",
"weight": "300grams"
}
]
}
//...
// In some script, insert the fake data to MongoDB
Object.keys(fakedModels).forEach(modelName => {
db[modelName.toLowerCase()].insertMany(fakedModels[modelName]);
});
API
options
exclude
: An array of model names for which data should not be generated. If ainclude
is provided, it only uses theinclude
models, ignoring theexclude
ones.include
: An array of model names for which data should be generated. If provided, it will only include the models in theinclude
. If neitherexclude
norinclude
is provided, it generates data for all models.itemsPerModel
: The number of fake objects (items) to be generated per model. Defaults to1
.modelType
: The model type for which the data should be generated. Defaults to 'core'.seed
: An integer to serve as the seed for the random data generation. Defaults to12
.